scriptup 2024.0.6 → 2026.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/ext/attribute_dictionaries.h +6 -1
- data/ext/attribute_dictionary.c +1 -0
- data/ext/attribute_dictionary.h +6 -1
- data/ext/behavior.h +6 -1
- data/ext/color.h +6 -1
- data/ext/component_definition.h +6 -1
- data/ext/component_instance.h +6 -1
- data/ext/definition_list.h +6 -1
- data/ext/drawing_element.c +135 -0
- data/ext/drawing_element.h +6 -1
- data/ext/entities.c +13 -0
- data/ext/entities.h +6 -1
- data/ext/entity.c +4 -0
- data/ext/entity.h +6 -1
- data/ext/extconf.rb +1 -1
- data/ext/material.h +6 -1
- data/ext/materials.h +6 -1
- data/ext/model.h +6 -1
- data/ext/not_implemented.c +88 -0
- data/ext/not_implemented.h +20 -0
- data/ext/sketchup.c +15 -0
- data/ext/sketchup.h +6 -1
- data/ext/texture.c +99 -0
- data/ext/texture.h +6 -1
- data/ext/typed_value.h +6 -0
- data/ext/utils.h +34 -3
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de7954cf033c906f4d616252f7e97ecfb2af66dabf09e2d2232667fbe2998b46
|
4
|
+
data.tar.gz: 914025ce525683c84f3dd7fd085fe724bea481dc150832142e38450a928d1279
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30ff6b2d9eaa4502d60470af7d69f08b7567bffba2ce0ee0d794511dff81ae44c057b70dd89597ede3869d6cd3cb54dfb39f87082a04fcad047401d68e9e49b6
|
7
|
+
data.tar.gz: a97541530c5ce94f7e0f56c80a8ba94c11da95a56f7199694b7163082e54aa4119175f636eba33ff4a3fc62194ac81c78a688a91086da9ae3704c83d4793e44b
|
data/README.md
CHANGED
@@ -12,13 +12,13 @@ The SketchUp C API is much more limmited than the ruby api. There is no gui eve
|
|
12
12
|
* Definition List
|
13
13
|
* Entity
|
14
14
|
* Material
|
15
|
+
* Drawingelement
|
16
|
+
* Texture
|
15
17
|
|
16
18
|
# Partially implemented classes
|
17
19
|
* Attribute Dictionaries
|
18
20
|
* Behavior
|
19
21
|
* Component Instance
|
20
|
-
* Drawing Element
|
21
22
|
* Entities
|
22
23
|
* Materials
|
23
|
-
* Model
|
24
|
-
* Texture
|
24
|
+
* Model
|
@@ -1,3 +1,8 @@
|
|
1
|
+
#ifndef SCRIPTUP_ATTRIBUTE_DICTIONARIES_H
|
2
|
+
#define SCRIPTUP_ATTRIBUTE_DICTIONARIES_H
|
3
|
+
|
1
4
|
#include <ruby.h>
|
2
5
|
|
3
|
-
VALUE AttributeDictionaries_Init(VALUE namespace_object, VALUE parent_class);
|
6
|
+
VALUE AttributeDictionaries_Init(VALUE namespace_object, VALUE parent_class);
|
7
|
+
|
8
|
+
#endif // SCRIPTUP_ATTRIBUTE_DICTIONARIES_H
|
data/ext/attribute_dictionary.c
CHANGED
@@ -153,5 +153,6 @@ VALUE AttributeDictionary_Init(VALUE Sketchup, VALUE Sketchup_Entity)
|
|
153
153
|
rb_define_method(Sketchup_AttributeDictionary, "keys", Sketchup_AttributeDictionary_keys, 0);
|
154
154
|
rb_define_method(Sketchup_AttributeDictionary, "values", Sketchup_AttributeDictionary_values, 0);
|
155
155
|
rb_define_method(Sketchup_AttributeDictionary, "delete_key", Sketchup_AttributeDictionary_delete_key, 1);
|
156
|
+
rb_define_alias(Sketchup_AttributeDictionary, "count", "size");
|
156
157
|
return Sketchup_AttributeDictionary;
|
157
158
|
}
|
data/ext/attribute_dictionary.h
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
#ifndef SCRIPTUP_ATTRIBUTE_DICTIONARY_H
|
2
|
+
#define SCRIPTUP_ATTRIBUTE_DICTIONARY_H
|
3
|
+
|
1
4
|
#include <ruby.h>
|
2
5
|
|
3
|
-
VALUE AttributeDictionary_Init(VALUE namespace_object, VALUE parent_class);
|
6
|
+
VALUE AttributeDictionary_Init(VALUE namespace_object, VALUE parent_class);
|
7
|
+
|
8
|
+
#endif // SCRIPTUP_ATTRIBUTE_DICTIONARY_H
|
data/ext/behavior.h
CHANGED
data/ext/color.h
CHANGED
data/ext/component_definition.h
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
#ifndef SCRIPTUP_COMPONENT_DEFINITION_H
|
2
|
+
#define SCRIPTUP_COMPONENT_DEFINITION_H
|
3
|
+
|
1
4
|
#include <ruby.h>
|
2
5
|
|
3
|
-
VALUE ComponentDefinition_Init(VALUE namespace_object, VALUE parent_class);
|
6
|
+
VALUE ComponentDefinition_Init(VALUE namespace_object, VALUE parent_class);
|
7
|
+
|
8
|
+
#endif // SCRIPTUP_COMPONENT_DEFINITION_H
|
data/ext/component_instance.h
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
#ifndef SCRIPTUP_COMPONENT_INSTANCE_H
|
2
|
+
#define SCRIPTUP_COMPONENT_INSTANCE_H
|
3
|
+
|
1
4
|
#include <ruby.h>
|
2
5
|
|
3
|
-
VALUE ComponentInstance_Init(VALUE namespace_object, VALUE parent_class);
|
6
|
+
VALUE ComponentInstance_Init(VALUE namespace_object, VALUE parent_class);
|
7
|
+
|
8
|
+
#endif // SCRIPTUP_COMPONENT_INSTANCE_H
|
data/ext/definition_list.h
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
#ifndef SCRIPTUP_DEFINITION_LIST_H
|
2
|
+
#define SCRIPTUP_DEFINITION_LIST_H
|
3
|
+
|
1
4
|
#include <ruby.h>
|
2
5
|
|
3
|
-
VALUE DefinitionList_Init(VALUE namespace_object, VALUE parent_class);
|
6
|
+
VALUE DefinitionList_Init(VALUE namespace_object, VALUE parent_class);
|
7
|
+
|
8
|
+
#endif // SCRIPTUP_DEFINITION_LIST_H
|
data/ext/drawing_element.c
CHANGED
@@ -1,11 +1,146 @@
|
|
1
1
|
#include <stdbool.h>
|
2
2
|
#include <drawing_element.h>
|
3
|
+
#include <not_implemented.h>
|
3
4
|
#include <utils.h>
|
4
5
|
#include <SketchUpAPI/sketchup.h>
|
5
6
|
|
7
|
+
static VALUE Sketchup_DrawingElement_bounds(VALUE self)
|
8
|
+
{
|
9
|
+
SUDrawingElementRef drawing_element = {DATA_PTR(self)};
|
10
|
+
struct SUBoundingBox3D* bbox = 0;
|
11
|
+
SUDrawingElementGetBoundingBox(drawing_element, bbox);
|
12
|
+
return Data_Make_Struct(rb_path2class(GEOM_BOUNDINGBOX), struct SUBoundingBox3D, 0, RUBY_DEFAULT_FREE, bbox);
|
13
|
+
}
|
14
|
+
|
15
|
+
static VALUE Sketchup_DrawingElement_Get_casts_shadows(VALUE self)
|
16
|
+
{
|
17
|
+
SUDrawingElementRef drawing_element = {DATA_PTR(self)};
|
18
|
+
bool casts_shadows_flag = false;
|
19
|
+
SUDrawingElementGetCastsShadows(drawing_element, &casts_shadows_flag);
|
20
|
+
return casts_shadows_flag ? Qtrue : Qfalse;
|
21
|
+
}
|
22
|
+
|
23
|
+
static VALUE Sketchup_DrawingElement_Set_casts_shadows(VALUE self, VALUE casts_shadows_flag)
|
24
|
+
{
|
25
|
+
SUDrawingElementRef drawing_element = {DATA_PTR(self)};
|
26
|
+
SUDrawingElementSetCastsShadows(drawing_element, RTEST(casts_shadows_flag));
|
27
|
+
return casts_shadows_flag;
|
28
|
+
}
|
29
|
+
|
30
|
+
static VALUE Sketchup_DrawingElement_Get_receives_shadows(VALUE self)
|
31
|
+
{
|
32
|
+
SUDrawingElementRef drawing_element = {DATA_PTR(self)};
|
33
|
+
bool receives_shadows_flag = false;
|
34
|
+
SUDrawingElementGetReceivesShadows(drawing_element, &receives_shadows_flag);
|
35
|
+
return receives_shadows_flag ? Qtrue : Qfalse;
|
36
|
+
}
|
37
|
+
|
38
|
+
static VALUE Sketchup_DrawingElement_Set_receives_shadows(VALUE self, VALUE receives_shadows_flag)
|
39
|
+
{
|
40
|
+
SUDrawingElementRef drawing_element = {DATA_PTR(self)};
|
41
|
+
SUDrawingElementSetReceivesShadows(drawing_element, RTEST(receives_shadows_flag));
|
42
|
+
return receives_shadows_flag;
|
43
|
+
}
|
44
|
+
|
45
|
+
static VALUE Sketchup_DrawingElement_Get_hidden(VALUE self)
|
46
|
+
{
|
47
|
+
SUDrawingElementRef drawing_element = {DATA_PTR(self)};
|
48
|
+
bool hide_flag = false;
|
49
|
+
SUDrawingElementGetHidden(drawing_element, &hide_flag);
|
50
|
+
return hide_flag ? Qtrue : Qfalse;
|
51
|
+
}
|
52
|
+
|
53
|
+
static VALUE Sketchup_DrawingElement_Set_hidden(VALUE self, VALUE hide_flag)
|
54
|
+
{
|
55
|
+
SUDrawingElementRef drawing_element = {DATA_PTR(self)};
|
56
|
+
SUDrawingElementSetHidden(drawing_element, RTEST(hide_flag));
|
57
|
+
return hide_flag;
|
58
|
+
}
|
59
|
+
|
60
|
+
static VALUE Sketchup_DrawingElement_Get_visible(VALUE self)
|
61
|
+
{
|
62
|
+
SUDrawingElementRef drawing_element = {DATA_PTR(self)};
|
63
|
+
bool hide_flag = false;
|
64
|
+
SUDrawingElementGetHidden(drawing_element, &hide_flag);
|
65
|
+
return hide_flag ? Qfalse : Qtrue;
|
66
|
+
}
|
67
|
+
|
68
|
+
static VALUE Sketchup_DrawingElement_Set_visible(VALUE self, VALUE visible_flag)
|
69
|
+
{
|
70
|
+
SUDrawingElementRef drawing_element = {DATA_PTR(self)};
|
71
|
+
SUDrawingElementSetHidden(drawing_element, RTEST(visible_flag));
|
72
|
+
return visible_flag;
|
73
|
+
}
|
74
|
+
|
75
|
+
static VALUE Sketchup_DrawingElement_Get_material(VALUE self)
|
76
|
+
{
|
77
|
+
SUDrawingElementRef drawing_element = {DATA_PTR(self)};
|
78
|
+
SUMaterialRef material = SU_INVALID;
|
79
|
+
SUDrawingElementGetMaterial(drawing_element, &material);
|
80
|
+
if (SUIsInvalid(material))
|
81
|
+
return Qnil;
|
82
|
+
return Data_Wrap_Struct(rb_path2class(SKETCHUP_MATERIAL), 0, 0, material.ptr);
|
83
|
+
}
|
84
|
+
|
85
|
+
static VALUE Sketchup_DrawingElement_Set_material(VALUE self, VALUE material)
|
86
|
+
{
|
87
|
+
SUDrawingElementRef drawing_element = {DATA_PTR(self)};
|
88
|
+
if (rb_type(material) == T_NIL)
|
89
|
+
{
|
90
|
+
SUMaterialRef empty_material = SU_INVALID;
|
91
|
+
SUDrawingElementSetMaterial(drawing_element, empty_material);
|
92
|
+
return Qnil;
|
93
|
+
}
|
94
|
+
if (!rb_obj_is_kind_of(material, rb_path2class(SKETCHUP_MATERIAL)))
|
95
|
+
rb_raise(rb_eTypeError, "Wrong type of object given");
|
96
|
+
|
97
|
+
SUMaterialRef drawing_element_material = {DATA_PTR(material)};
|
98
|
+
SUDrawingElementSetMaterial(drawing_element, drawing_element_material);
|
99
|
+
return material;
|
100
|
+
}
|
101
|
+
|
102
|
+
static VALUE Sketchup_DrawingElement_Get_layer(VALUE self)
|
103
|
+
{
|
104
|
+
SUDrawingElementRef drawing_element = {DATA_PTR(self)};
|
105
|
+
SULayerRef layer = SU_INVALID;
|
106
|
+
SUDrawingElementGetLayer(drawing_element, &layer);
|
107
|
+
return Data_Wrap_Struct(rb_path2class(SKETCHUP_LAYER), 0, 0, layer.ptr);
|
108
|
+
}
|
109
|
+
|
110
|
+
static VALUE Sketchup_DrawingElement_Set_layer(VALUE self, VALUE layer)
|
111
|
+
{
|
112
|
+
if (rb_type(layer) == T_NIL)
|
113
|
+
{
|
114
|
+
SUDrawingElementRef drawing_element = {DATA_PTR(self)};
|
115
|
+
SULayerRef drawing_element_layer = SU_INVALID;
|
116
|
+
SUDrawingElementSetLayer(drawing_element, drawing_element_layer);
|
117
|
+
return Qnil;
|
118
|
+
}
|
119
|
+
if (!rb_obj_is_kind_of(layer, rb_path2class(SKETCHUP_LAYER)))
|
120
|
+
rb_raise(rb_eArgError, "Wrong type of object given");
|
121
|
+
|
122
|
+
SUDrawingElementRef drawing_element = {DATA_PTR(self)};
|
123
|
+
SULayerRef drawing_element_layer = {DATA_PTR(layer)};
|
124
|
+
SUDrawingElementSetLayer(drawing_element, drawing_element_layer);
|
125
|
+
return layer;
|
126
|
+
}
|
127
|
+
|
6
128
|
VALUE DrawingElement_Init(VALUE Sketchup, VALUE Sketchup_Entity)
|
7
129
|
{
|
8
130
|
VALUE Sketchup_DrawingElement = rb_define_class_under(Sketchup, DRAWINGELEMENT, Sketchup_Entity);
|
9
131
|
rb_undef_alloc_func(Sketchup_DrawingElement);
|
132
|
+
rb_define_method(Sketchup_DrawingElement, "bounds", Sketchup_DrawingElement_bounds, 0);
|
133
|
+
rb_define_method(Sketchup_DrawingElement, "casts_shadows?", Sketchup_DrawingElement_Get_casts_shadows, 0);
|
134
|
+
rb_define_method(Sketchup_DrawingElement, "casts_shadows=", Sketchup_DrawingElement_Set_casts_shadows, 1);
|
135
|
+
rb_define_method(Sketchup_DrawingElement, "receives_shadows?", Sketchup_DrawingElement_Get_receives_shadows, 0);
|
136
|
+
rb_define_method(Sketchup_DrawingElement, "receives_shadows=", Sketchup_DrawingElement_Set_receives_shadows, 1);
|
137
|
+
rb_define_method(Sketchup_DrawingElement, "hidden?", Sketchup_DrawingElement_Get_hidden, 0);
|
138
|
+
rb_define_method(Sketchup_DrawingElement, "hidden=", Sketchup_DrawingElement_Set_hidden, 1);
|
139
|
+
rb_define_method(Sketchup_DrawingElement, "visible?", Sketchup_DrawingElement_Get_visible, 0);
|
140
|
+
rb_define_method(Sketchup_DrawingElement, "visible=", Sketchup_DrawingElement_Set_visible, 1);
|
141
|
+
rb_define_method(Sketchup_DrawingElement, "material", Sketchup_DrawingElement_Get_material, 0);
|
142
|
+
rb_define_method(Sketchup_DrawingElement, "material=", Sketchup_DrawingElement_Set_material, 1);
|
143
|
+
rb_define_method(Sketchup_DrawingElement, "layer", Sketchup_DrawingElement_Get_layer, 0);
|
144
|
+
rb_define_method(Sketchup_DrawingElement, "layer=", Sketchup_DrawingElement_Set_layer, 1);
|
10
145
|
return Sketchup_DrawingElement;
|
11
146
|
}
|
data/ext/drawing_element.h
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
#ifndef SCRIPTUP_DRAWING_ELEMENT_H
|
2
|
+
#define SCRIPTUP_DRAWING_ELEMENT_H
|
3
|
+
|
1
4
|
#include <ruby.h>
|
2
5
|
|
3
|
-
VALUE DrawingElement_Init(VALUE namespace_object, VALUE parent_class);
|
6
|
+
VALUE DrawingElement_Init(VALUE namespace_object, VALUE parent_class);
|
7
|
+
|
8
|
+
#endif // SCRIPTUP_DRAWING_ELEMENT_H
|
data/ext/entities.c
CHANGED
@@ -3,10 +3,23 @@
|
|
3
3
|
#include <SketchUpAPI/sketchup.h>
|
4
4
|
#include <utils.h>
|
5
5
|
|
6
|
+
void Sketchup_Entities_Iterator(SUFaceRef face, void* _)
|
7
|
+
{
|
8
|
+
rb_yield(Data_Wrap_Struct(rb_path2class(SKETCHUP_FACE), 0, 0, face.ptr));
|
9
|
+
}
|
10
|
+
|
11
|
+
static VALUE Sketchup_Entities_each(VALUE self)
|
12
|
+
{
|
13
|
+
SUEntitiesRef entities = {DATA_PTR(self)};
|
14
|
+
FOREACH(SUEntitiesGetNumFaces, SUEntitiesGetFaces, SUFaceRef, entities, Sketchup_Entities_Iterator, 0);
|
15
|
+
return self;
|
16
|
+
}
|
6
17
|
|
7
18
|
VALUE Entities_Init(VALUE Sketchup, VALUE rb_cObject)
|
8
19
|
{
|
9
20
|
VALUE Sketchup_Entities = rb_define_class_under(Sketchup, ENTITIES, rb_cObject);
|
10
21
|
rb_undef_alloc_func(Sketchup_Entities);
|
22
|
+
rb_include_module(Sketchup_Entities, rb_mEnumerable);
|
23
|
+
rb_define_method(Sketchup_Entities, "each", Sketchup_Entities_each, 0);
|
11
24
|
return Sketchup_Entities;
|
12
25
|
}
|
data/ext/entities.h
CHANGED
data/ext/entity.c
CHANGED
@@ -159,6 +159,10 @@ void Sketchup_Entity_attribute_dictionary_Iterator(SUAttributeDictionaryRef dict
|
|
159
159
|
|
160
160
|
static VALUE Sketchup_Entity_attribute_dictionary(int argc, VALUE* argv, VALUE self)
|
161
161
|
{
|
162
|
+
if (rb_obj_is_kind_of(self, rb_path2class(SKETCHUP_MATERIALS)))
|
163
|
+
return Qnil;
|
164
|
+
if (rb_obj_is_kind_of(self, rb_path2class(SKETCHUP_DEFINITIONLIST)))
|
165
|
+
return Qnil;
|
162
166
|
SUEntityRef entity = {DATA_PTR(self)};
|
163
167
|
struct AttributeDictionaryIterationContext attribute_dictionary_struct = {argv[0], SU_INVALID};
|
164
168
|
FOREACH(SUEntityGetNumAttributeDictionaries, SUEntityGetAttributeDictionaries, SUAttributeDictionaryRef, entity, Sketchup_Entity_attribute_dictionary_Iterator, &attribute_dictionary_struct);
|
data/ext/entity.h
CHANGED
data/ext/extconf.rb
CHANGED
@@ -27,7 +27,7 @@ $CFLAGS << " #{'-Werror' if MAC } -O0 " if ENV['SCRIPTUP_DEVELOPMENT']
|
|
27
27
|
|
28
28
|
if MAC
|
29
29
|
$DLDFLAGS.gsub!('-Wl,-multiply_defined,suppress', '')
|
30
|
-
$DLDFLAGS << ' -Wl
|
30
|
+
$DLDFLAGS << ' -Wl'
|
31
31
|
$DLDFLAGS << " -F#{sdk_path} -framework SketchUpAPI"
|
32
32
|
$DLDFLAGS << " -Wl,-rpath,#{sdk_path}"
|
33
33
|
else
|
data/ext/material.h
CHANGED
data/ext/materials.h
CHANGED
data/ext/model.h
CHANGED
@@ -0,0 +1,88 @@
|
|
1
|
+
#include <stdbool.h>
|
2
|
+
#include <not_implemented.h>
|
3
|
+
#include <utils.h>
|
4
|
+
#include <SketchUpAPI/sketchup.h>
|
5
|
+
|
6
|
+
VALUE BoundingBox_Init(VALUE Geom, VALUE Sketchup_Object)
|
7
|
+
{
|
8
|
+
VALUE Geom_BoundingBox = rb_define_class_under(Geom, BOUNDINGBOX, Sketchup_Object);
|
9
|
+
rb_undef_alloc_func(Geom_BoundingBox);
|
10
|
+
return Geom_BoundingBox;
|
11
|
+
}
|
12
|
+
|
13
|
+
VALUE Face_Init(VALUE Sketchup, VALUE DrawingElement)
|
14
|
+
{
|
15
|
+
VALUE Sketchup_Face = rb_define_class_under(Sketchup, FACE, DrawingElement);
|
16
|
+
rb_undef_alloc_func(Sketchup_Face);
|
17
|
+
return Sketchup_Face;
|
18
|
+
}
|
19
|
+
|
20
|
+
VALUE Layer_Init(VALUE Sketchup, VALUE Entity)
|
21
|
+
{
|
22
|
+
VALUE Sketchup_Layer = rb_define_class_under(Sketchup, LAYER, Entity);
|
23
|
+
rb_undef_alloc_func(Sketchup_Layer);
|
24
|
+
return Sketchup_Layer;
|
25
|
+
}
|
26
|
+
|
27
|
+
VALUE ConstructionLine_Init(VALUE Sketchup, VALUE DrawingElement)
|
28
|
+
{
|
29
|
+
VALUE Sketchup_ConstructionLine = rb_define_class_under(Sketchup, CONSTRUCTIONLINE, DrawingElement);
|
30
|
+
rb_undef_alloc_func(Sketchup_ConstructionLine);
|
31
|
+
return Sketchup_ConstructionLine;
|
32
|
+
}
|
33
|
+
|
34
|
+
VALUE ConstructionPoint_Init(VALUE Sketchup, VALUE DrawingElement)
|
35
|
+
{
|
36
|
+
VALUE Sketchup_ConstructionPoint = rb_define_class_under(Sketchup, CONSTRUCTIONPOINT, DrawingElement);
|
37
|
+
rb_undef_alloc_func(Sketchup_ConstructionPoint);
|
38
|
+
return Sketchup_ConstructionPoint;
|
39
|
+
}
|
40
|
+
|
41
|
+
VALUE Dimension_Init(VALUE Sketchup, VALUE DrawingElement)
|
42
|
+
{
|
43
|
+
VALUE Sketchup_Dimension = rb_define_class_under(Sketchup, DIMENSION, DrawingElement);
|
44
|
+
rb_undef_alloc_func(Sketchup_Dimension);
|
45
|
+
return Sketchup_Dimension;
|
46
|
+
}
|
47
|
+
|
48
|
+
VALUE Edge_Init(VALUE Sketchup, VALUE DrawingElement)
|
49
|
+
{
|
50
|
+
VALUE Sketchup_Edge = rb_define_class_under(Sketchup, EDGE, DrawingElement);
|
51
|
+
rb_undef_alloc_func(Sketchup_Edge);
|
52
|
+
return Sketchup_Edge;
|
53
|
+
}
|
54
|
+
|
55
|
+
VALUE Group_Init(VALUE Sketchup, VALUE DrawingElement)
|
56
|
+
{
|
57
|
+
VALUE Sketchup_Group = rb_define_class_under(Sketchup, GROUP, DrawingElement);
|
58
|
+
rb_undef_alloc_func(Sketchup_Group);
|
59
|
+
return Sketchup_Group;
|
60
|
+
}
|
61
|
+
|
62
|
+
VALUE Image_Init(VALUE Sketchup, VALUE DrawingElement)
|
63
|
+
{
|
64
|
+
VALUE Sketchup_Image = rb_define_class_under(Sketchup, IMAGE, DrawingElement);
|
65
|
+
rb_undef_alloc_func(Sketchup_Image);
|
66
|
+
return Sketchup_Image;
|
67
|
+
}
|
68
|
+
|
69
|
+
VALUE SectionPlane_Init(VALUE Sketchup, VALUE DrawingElement)
|
70
|
+
{
|
71
|
+
VALUE Sketchup_SectionPlane = rb_define_class_under(Sketchup, SECTIONPLANE, DrawingElement);
|
72
|
+
rb_undef_alloc_func(Sketchup_SectionPlane);
|
73
|
+
return Sketchup_SectionPlane;
|
74
|
+
}
|
75
|
+
|
76
|
+
VALUE Text_Init(VALUE Sketchup, VALUE DrawingElement)
|
77
|
+
{
|
78
|
+
VALUE Sketchup_Text = rb_define_class_under(Sketchup, TEXT, DrawingElement);
|
79
|
+
rb_undef_alloc_func(Sketchup_Text);
|
80
|
+
return Sketchup_Text;
|
81
|
+
}
|
82
|
+
|
83
|
+
VALUE ImageRep_Init(VALUE Sketchup, VALUE Sketchup_Object)
|
84
|
+
{
|
85
|
+
VALUE Sketchup_ImageRep = rb_define_class_under(Sketchup, IMAGEREP, Sketchup_Object);
|
86
|
+
rb_undef_alloc_func(Sketchup_ImageRep);
|
87
|
+
return Sketchup_ImageRep;
|
88
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#ifndef SCRIPTUP_NOT_IMPLEMENTED_H
|
2
|
+
#define SCRIPTUP_NOT_IMPLEMENTED_H
|
3
|
+
|
4
|
+
#include <ruby.h>
|
5
|
+
|
6
|
+
VALUE BoundingBox_Init(VALUE namespace_object, VALUE parent_class);
|
7
|
+
VALUE Face_Init(VALUE namespace_object, VALUE parent_class);
|
8
|
+
VALUE Layer_Init(VALUE namespace_object, VALUE parent_class);
|
9
|
+
VALUE ConstructionLine_Init(VALUE namespace_object, VALUE parent_class);
|
10
|
+
VALUE ConstructionPoint_Init(VALUE namespace_object, VALUE parent_class);
|
11
|
+
VALUE Dimension_Init(VALUE namespace_object, VALUE parent_class);
|
12
|
+
VALUE Edge_Init(VALUE namespace_object, VALUE parent_class);
|
13
|
+
VALUE Group_Init(VALUE namespace_object, VALUE parent_class);
|
14
|
+
VALUE Image_Init(VALUE namespace_object, VALUE parent_class);
|
15
|
+
VALUE SectionPlane_Init(VALUE namespace_object, VALUE parent_class);
|
16
|
+
VALUE Text_Init(VALUE namespace_object, VALUE parent_class);
|
17
|
+
VALUE ImageRep_Init(VALUE namespace_object, VALUE parent_class);
|
18
|
+
|
19
|
+
|
20
|
+
#endif // SCRIPTUP_NOT_IMPLEMENTED_H
|
data/ext/sketchup.c
CHANGED
@@ -15,6 +15,7 @@
|
|
15
15
|
#include <definition_list.h>
|
16
16
|
#include <drawing_element.h>
|
17
17
|
#include <behavior.h>
|
18
|
+
#include <not_implemented.h>
|
18
19
|
#include <utils.h>
|
19
20
|
|
20
21
|
SUModelRef active_model = SU_INVALID;
|
@@ -72,6 +73,7 @@ void Init_sketchup() {
|
|
72
73
|
|
73
74
|
Model_Init(Sketchup, rb_cObject);
|
74
75
|
Color_Init(Sketchup, rb_cObject);
|
76
|
+
ImageRep_Init(Sketchup, rb_cObject);
|
75
77
|
|
76
78
|
Entities_Init(Sketchup, rb_cObject);
|
77
79
|
VALUE Sketchup_Entity = Entity_Init(Sketchup, rb_cObject);
|
@@ -82,8 +84,21 @@ void Init_sketchup() {
|
|
82
84
|
AttributeDictionaries_Init(Sketchup, Sketchup_Entity);
|
83
85
|
Texture_Init(Sketchup, Sketchup_Entity);
|
84
86
|
Behavior_Init(Sketchup, Sketchup_Entity);
|
87
|
+
Layer_Init(Sketchup, Sketchup_Entity);
|
85
88
|
|
89
|
+
VALUE Geom = rb_define_module(GEOM);
|
90
|
+
BoundingBox_Init(Geom, rb_cObject);
|
91
|
+
|
86
92
|
VALUE Sketchup_DrawingElement = DrawingElement_Init(Sketchup, Sketchup_Entity);
|
87
93
|
ComponentInstance_Init(Sketchup, Sketchup_DrawingElement);
|
88
94
|
ComponentDefinition_Init(Sketchup, Sketchup_DrawingElement);
|
95
|
+
Face_Init(Sketchup, Sketchup_DrawingElement);
|
96
|
+
ConstructionLine_Init(Sketchup, Sketchup_DrawingElement);
|
97
|
+
ConstructionPoint_Init(Sketchup, Sketchup_DrawingElement);
|
98
|
+
Dimension_Init(Sketchup, Sketchup_DrawingElement);
|
99
|
+
Edge_Init(Sketchup, Sketchup_DrawingElement);
|
100
|
+
Group_Init(Sketchup, Sketchup_DrawingElement);
|
101
|
+
Image_Init(Sketchup, Sketchup_DrawingElement);
|
102
|
+
SectionPlane_Init(Sketchup, Sketchup_DrawingElement);
|
103
|
+
Text_Init(Sketchup, Sketchup_DrawingElement);
|
89
104
|
}
|
data/ext/sketchup.h
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
+
#ifndef SCRIPTUP_SKETCHUP_H
|
2
|
+
#define SCRIPTUP_SKETCHUP_H
|
3
|
+
|
1
4
|
#include <SketchUpAPI/sketchup.h>
|
2
5
|
|
3
6
|
SUModelRef Sketchup_get_active_model();
|
4
|
-
void Sketchup_set_active_model(SUModelRef model);
|
7
|
+
void Sketchup_set_active_model(SUModelRef model);
|
8
|
+
|
9
|
+
#endif // SCRIPTUP_SKETCHUP_H
|
data/ext/texture.c
CHANGED
@@ -1,10 +1,109 @@
|
|
1
1
|
#include <stdbool.h>
|
2
2
|
#include <texture.h>
|
3
3
|
#include <SketchUpAPI/sketchup.h>
|
4
|
+
#include <not_implemented.h>
|
4
5
|
#include <utils.h>
|
5
6
|
|
7
|
+
static VALUE Sketchup_Texture_average_color(VALUE self)
|
8
|
+
{
|
9
|
+
SUTextureRef texture = {DATA_PTR(self)};
|
10
|
+
VALUE c = rb_obj_alloc(rb_path2class(SKETCHUP_COLOR));
|
11
|
+
SUColor* color = DATA_PTR(c);
|
12
|
+
enum SUResult result = SUTextureGetAverageColor(texture, color);
|
13
|
+
if (result != SU_ERROR_NONE)
|
14
|
+
return Qnil;
|
15
|
+
return c;
|
16
|
+
}
|
17
|
+
|
18
|
+
static VALUE Sketchup_Texture_filename(VALUE self)
|
19
|
+
{
|
20
|
+
SUTextureRef texture = {DATA_PTR(self)};
|
21
|
+
VALUE output;
|
22
|
+
GETSTRING(SUTextureGetFileName, texture, output);
|
23
|
+
return output;
|
24
|
+
}
|
25
|
+
|
26
|
+
static VALUE Sketchup_Texture_image_height(VALUE self)
|
27
|
+
{
|
28
|
+
SUTextureRef texture = {DATA_PTR(self)};
|
29
|
+
size_t width = 0;
|
30
|
+
size_t height = 0;
|
31
|
+
double s_scale = 0.0;
|
32
|
+
double t_scale = 0.0;
|
33
|
+
SUTextureGetDimensions(texture, &width, &height, &s_scale, &t_scale);
|
34
|
+
return ULL2NUM(height);
|
35
|
+
}
|
36
|
+
|
37
|
+
static VALUE Sketchup_Texture_height(VALUE self)
|
38
|
+
{
|
39
|
+
SUTextureRef texture = {DATA_PTR(self)};
|
40
|
+
size_t width = 0;
|
41
|
+
size_t height = 0;
|
42
|
+
double s_scale = 0.0;
|
43
|
+
double t_scale = 0.0;
|
44
|
+
SUTextureGetDimensions(texture, &width, &height, &s_scale, &t_scale);
|
45
|
+
return DBL2NUM(1.0 / t_scale);
|
46
|
+
}
|
47
|
+
|
48
|
+
static VALUE Sketchup_Texture_width(VALUE self)
|
49
|
+
{
|
50
|
+
SUTextureRef texture = {DATA_PTR(self)};
|
51
|
+
size_t width = 0;
|
52
|
+
size_t height = 0;
|
53
|
+
double s_scale = 0.0;
|
54
|
+
double t_scale = 0.0;
|
55
|
+
SUTextureGetDimensions(texture, &width, &height, &s_scale, &t_scale);
|
56
|
+
return DBL2NUM(1.0 / s_scale);
|
57
|
+
}
|
58
|
+
|
59
|
+
static VALUE Sketchup_Texture_image_width(VALUE self)
|
60
|
+
{
|
61
|
+
SUTextureRef texture = {DATA_PTR(self)};
|
62
|
+
size_t width = 0;
|
63
|
+
size_t height = 0;
|
64
|
+
double s_scale = 0.0;
|
65
|
+
double t_scale = 0.0;
|
66
|
+
SUTextureGetDimensions(texture, &width, &height, &s_scale, &t_scale);
|
67
|
+
return ULL2NUM(width);
|
68
|
+
}
|
69
|
+
|
70
|
+
static VALUE Sketchup_Texture_image_rep(VALUE self)
|
71
|
+
{
|
72
|
+
SUTextureRef texture = {DATA_PTR(self)};
|
73
|
+
SUImageRepRef image = SU_INVALID;
|
74
|
+
SUTextureGetImageRep(texture, &image);
|
75
|
+
return Data_Wrap_Struct(rb_path2class(SKETCHUP_IMAGEREP), 0, 0, image.ptr);
|
76
|
+
}
|
77
|
+
|
78
|
+
static VALUE Sketchup_Texture_Get_valid(VALUE self)
|
79
|
+
{
|
80
|
+
SUTextureRef texture = {DATA_PTR(self)};
|
81
|
+
return SUIsValid(texture) ? Qtrue : Qfalse;
|
82
|
+
}
|
83
|
+
|
84
|
+
static VALUE Sketchup_Texture_write(VALUE self, VALUE path, VALUE colorize)
|
85
|
+
{
|
86
|
+
SUTextureRef texture = {DATA_PTR(self)};
|
87
|
+
const char* path_ptr = StringValuePtr(path);
|
88
|
+
enum SUResult result = SU_ERROR_UNSUPPORTED;
|
89
|
+
if (RTEST(colorize))
|
90
|
+
result = SUTextureWriteToFile(texture, path_ptr);
|
91
|
+
else
|
92
|
+
result = SUTextureWriteOriginalToFile(texture, path_ptr);
|
93
|
+
return result != SU_ERROR_NONE ? Qfalse : Qtrue;
|
94
|
+
}
|
95
|
+
|
6
96
|
void Texture_Init(VALUE Sketchup, VALUE Sketchup_Entity)
|
7
97
|
{
|
8
98
|
VALUE Sketchup_Texture = rb_define_class_under(Sketchup, TEXTURE, Sketchup_Entity);
|
9
99
|
rb_undef_alloc_func(Sketchup_Texture);
|
100
|
+
rb_define_method(Sketchup_Texture, "average_color", Sketchup_Texture_average_color, 0);
|
101
|
+
rb_define_method(Sketchup_Texture, "filename", Sketchup_Texture_filename, 0);
|
102
|
+
rb_define_method(Sketchup_Texture, "image_height", Sketchup_Texture_image_height, 0);
|
103
|
+
rb_define_method(Sketchup_Texture, "height", Sketchup_Texture_height, 0);
|
104
|
+
rb_define_method(Sketchup_Texture, "image_width", Sketchup_Texture_image_width, 0);
|
105
|
+
rb_define_method(Sketchup_Texture, "width", Sketchup_Texture_width, 0);
|
106
|
+
rb_define_method(Sketchup_Texture, "image_rep", Sketchup_Texture_image_rep, 0);
|
107
|
+
rb_define_method(Sketchup_Texture, "valid?", Sketchup_Texture_Get_valid, 0);
|
108
|
+
rb_define_method(Sketchup_Texture, "write", Sketchup_Texture_write, 2);
|
10
109
|
}
|
data/ext/texture.h
CHANGED
data/ext/typed_value.h
CHANGED
@@ -1,5 +1,11 @@
|
|
1
|
+
#ifndef SCRIPTUP_TYPED_VALUE_H
|
2
|
+
#define SCRIPTUP_TYPED_VALUE_H
|
3
|
+
|
1
4
|
#include <ruby.h>
|
2
5
|
#include <SketchUpAPI/sketchup.h>
|
3
6
|
|
4
7
|
VALUE TypedValue_get_value_type(SUTypedValueRef* typedValue);
|
5
8
|
VALUE TypedValue_set_value_type(SUTypedValueRef* typedValue, VALUE value);
|
9
|
+
|
10
|
+
|
11
|
+
#endif // SCRIPTUP_TYPED_VALUE_H
|
data/ext/utils.h
CHANGED
@@ -1,7 +1,13 @@
|
|
1
|
+
#ifndef SCRIPTUP_UTILS_H
|
2
|
+
#define SCRIPTUP_UTILS_H
|
3
|
+
|
1
4
|
#include <ruby.h>
|
2
5
|
|
3
|
-
#
|
6
|
+
#ifdef TEXT
|
7
|
+
#undef TEXT
|
8
|
+
#endif //TEXT
|
4
9
|
#define SKETCHUP "Sketchup"
|
10
|
+
#define GEOM "Geom"
|
5
11
|
#define MODEL "Model"
|
6
12
|
#define MATERIAL "Material"
|
7
13
|
#define MATERIALS "Materials"
|
@@ -16,6 +22,18 @@
|
|
16
22
|
#define ATTRIBUTEDICTIONARIES "AttributeDictionaries"
|
17
23
|
#define DRAWINGELEMENT "DrawingElement"
|
18
24
|
#define BEHAVIOR "Behavior"
|
25
|
+
#define BOUNDINGBOX "BoundingBox"
|
26
|
+
#define FACE "Face"
|
27
|
+
#define LAYER "Layer"
|
28
|
+
#define CONSTRUCTIONLINE "ConstructionLine"
|
29
|
+
#define CONSTRUCTIONPOINT "ConstructionPoint"
|
30
|
+
#define DIMENSION "Dimension"
|
31
|
+
#define EDGE "Edge"
|
32
|
+
#define IMAGE "Image"
|
33
|
+
#define SECTIONPLANE "SectionPlane"
|
34
|
+
#define GROUP "Group"
|
35
|
+
#define TEXT "Text"
|
36
|
+
#define IMAGEREP "ImageRep"
|
19
37
|
#define SKETCHUP_MATERIAL SKETCHUP "::" MATERIAL
|
20
38
|
#define SKETCHUP_MATERIALS SKETCHUP "::" MATERIALS
|
21
39
|
#define SKETCHUP_TEXTURE SKETCHUP "::" TEXTURE
|
@@ -28,6 +46,18 @@
|
|
28
46
|
#define SKETCHUP_ATTRIBUTEDICTIONARIES SKETCHUP "::" ATTRIBUTEDICTIONARIES
|
29
47
|
#define SKETCHUP_DEFINITIONLIST SKETCHUP "::" DEFINITIONLIST
|
30
48
|
#define SKETCHUP_BEHAVIOR SKETCHUP "::" BEHAVIOR
|
49
|
+
#define GEOM_BOUNDINGBOX GEOM "::" BOUNDINGBOX
|
50
|
+
#define SKETCHUP_FACE SKETCHUP "::" FACE
|
51
|
+
#define SKETCHUP_LAYER SKETCHUP "::" LAYER
|
52
|
+
#define SKETCHUP_CONSTRUCTIONLINE SKETCHUP "::" CONSTRUCTIONLINE
|
53
|
+
#define SKETCHUP_CONSTRUCTIONPOINT SKETCHUP "::" CONSTRUCTIONPOINT
|
54
|
+
#define SKETCHUP_DIMENSION SKETCHUP "::" DIMENSION
|
55
|
+
#define SKETCHUP_EDGER SKETCHUP "::" EDGE
|
56
|
+
#define SKETCHUP_IMAGE SKETCHUP "::" IMAGE
|
57
|
+
#define SKETCHUP_SECTIONPLANE SKETCHUP "::" SECTIONPLANE
|
58
|
+
#define SKETCHUP_GROUP SKETCHUP "::" GROUP
|
59
|
+
#define SKETCHUP_TEXT SKETCHUP "::" TEXT
|
60
|
+
#define SKETCHUP_IMAGEREP SKETCHUP "::" IMAGEREP
|
31
61
|
|
32
62
|
#pragma clang diagnostic push
|
33
63
|
#pragma clang diagnostic ignored "-Wbackslash-newline-escape"
|
@@ -75,6 +105,7 @@
|
|
75
105
|
GETUTF8FROMSTRING(name, output); \
|
76
106
|
SUStringRelease(&name); \
|
77
107
|
}
|
78
|
-
#endif // UTILS_H
|
79
108
|
|
80
|
-
#pragma clang diagnostic pop
|
109
|
+
#pragma clang diagnostic pop
|
110
|
+
|
111
|
+
#endif // SCRIPTUP_UTILS_H
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scriptup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2026.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Noel Warren
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -77,6 +77,8 @@ files:
|
|
77
77
|
- ext/materials.h
|
78
78
|
- ext/model.c
|
79
79
|
- ext/model.h
|
80
|
+
- ext/not_implemented.c
|
81
|
+
- ext/not_implemented.h
|
80
82
|
- ext/sketchup.c
|
81
83
|
- ext/sketchup.h
|
82
84
|
- ext/texture.c
|
@@ -339,7 +341,7 @@ homepage: https://git.chaosgroup.com/sketchup/sketchup-ruby-bindings
|
|
339
341
|
licenses:
|
340
342
|
- BSD-3-Clause
|
341
343
|
metadata: {}
|
342
|
-
post_install_message:
|
344
|
+
post_install_message:
|
343
345
|
rdoc_options: []
|
344
346
|
require_paths:
|
345
347
|
- lib
|
@@ -355,7 +357,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
355
357
|
version: '0'
|
356
358
|
requirements: []
|
357
359
|
rubygems_version: 3.1.6
|
358
|
-
signing_key:
|
360
|
+
signing_key:
|
359
361
|
specification_version: 4
|
360
362
|
summary: Ruby bindings for the SketchUp C API
|
361
363
|
test_files: []
|