scriptup 2026.0.1 → 2026.0.2
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 +43 -24
- data/ext/arc_curve.c +50 -0
- data/ext/attribute_dictionaries.c +49 -32
- data/ext/attribute_dictionary.c +54 -127
- data/ext/axes.c +79 -0
- data/ext/behavior.c +100 -9
- data/ext/bounding_box.c +195 -0
- data/ext/camera.c +178 -0
- data/ext/classifications.c +85 -0
- data/ext/color.c +91 -163
- data/ext/component_definition.c +78 -162
- data/ext/component_instance.c +88 -9
- data/ext/construction.c +59 -0
- data/ext/curve.c +87 -0
- data/ext/definition_list.c +89 -109
- data/ext/depend +1 -0
- data/ext/drawing_element.c +96 -117
- data/ext/edge.c +147 -0
- data/ext/edge_use.c +37 -0
- data/ext/entities.c +573 -16
- data/ext/entities_builder.c +145 -0
- data/ext/entity.c +175 -215
- data/ext/environments.c +149 -0
- data/ext/extconf.rb +54 -10
- data/ext/face.c +331 -0
- data/ext/geom.c +172 -0
- data/ext/group.c +86 -0
- data/ext/helpers.c +244 -0
- data/ext/image.c +182 -0
- data/ext/image_rep.c +158 -0
- data/ext/instance_path.c +185 -0
- data/ext/lat_long.c +88 -0
- data/ext/layer.c +98 -0
- data/ext/layer_folder.c +99 -0
- data/ext/layers.c +122 -0
- data/ext/length.c +253 -0
- data/ext/line_styles.c +60 -0
- data/ext/loop.c +24 -0
- data/ext/material.c +144 -197
- data/ext/materials.c +49 -60
- data/ext/model.c +232 -26
- data/ext/options_store.c +188 -0
- data/ext/page.c +168 -0
- data/ext/pages.c +135 -0
- data/ext/point2d.c +195 -0
- data/ext/point3d.c +340 -0
- data/ext/polygon_mesh.c +253 -0
- data/ext/scriptup.h +279 -0
- data/ext/section_plane.c +44 -0
- data/ext/sketchup.c +102 -76
- data/ext/styles.c +91 -0
- data/ext/text.c +135 -0
- data/ext/texture.c +74 -83
- data/ext/texture_writer.c +104 -0
- data/ext/transformation.c +309 -0
- data/ext/transformation2d.c +190 -0
- data/ext/uv_helper.c +41 -0
- data/ext/vector2d.c +238 -0
- data/ext/vector3d.c +294 -0
- data/ext/vertex.c +67 -0
- data/lib/sketchup.rb +2 -2
- data/sig/_top_level.rbs +188 -0
- data/sig/array.rbs +52 -0
- data/sig/geom/bounding_box.rbs +28 -0
- data/sig/geom/bounds2d.rbs +20 -0
- data/sig/geom/lat_long.rbs +13 -0
- data/sig/geom/oriented_bounds2d.rbs +10 -0
- data/sig/geom/point2d.rbs +32 -0
- data/sig/geom/point3d.rbs +46 -0
- data/sig/geom/polygon_mesh.rbs +35 -0
- data/sig/geom/transformation.rbs +44 -0
- data/sig/geom/transformation2d.rbs +26 -0
- data/sig/geom/utm.rbs +14 -0
- data/sig/geom/vector2d.rbs +40 -0
- data/sig/geom/vector3d.rbs +49 -0
- data/sig/geom.rbs +25 -0
- data/sig/language_handler.rbs +8 -0
- data/sig/layout/angular_dimension.rbs +32 -0
- data/sig/layout/auto_text_definition.rbs +73 -0
- data/sig/layout/auto_text_definitions.rbs +15 -0
- data/sig/layout/connection_point.rbs +6 -0
- data/sig/layout/dictionary.rbs +18 -0
- data/sig/layout/document.rbs +61 -0
- data/sig/layout/ellipse.rbs +5 -0
- data/sig/layout/entities.rbs +10 -0
- data/sig/layout/entity.rbs +28 -0
- data/sig/layout/formatted_text.rbs +30 -0
- data/sig/layout/grid.rbs +24 -0
- data/sig/layout/group.rbs +17 -0
- data/sig/layout/image.rbs +7 -0
- data/sig/layout/label.rbs +31 -0
- data/sig/layout/layer.rbs +21 -0
- data/sig/layout/layer_instance.rbs +9 -0
- data/sig/layout/layers.rbs +18 -0
- data/sig/layout/linear_dimension.rbs +39 -0
- data/sig/layout/locked_entity_error.rbs +4 -0
- data/sig/layout/locked_layer_error.rbs +4 -0
- data/sig/layout/page.rbs +20 -0
- data/sig/layout/page_info.rbs +37 -0
- data/sig/layout/pages.rbs +17 -0
- data/sig/layout/path.rbs +34 -0
- data/sig/layout/rectangle.rbs +15 -0
- data/sig/layout/reference_entity.rbs +7 -0
- data/sig/layout/sketch_up_model.rbs +54 -0
- data/sig/layout/style.rbs +150 -0
- data/sig/layout/table.rbs +17 -0
- data/sig/layout/table_cell.rbs +13 -0
- data/sig/layout/table_column.rbs +10 -0
- data/sig/layout/table_row.rbs +10 -0
- data/sig/layout.rbs +4 -0
- data/sig/length.rbs +37 -0
- data/sig/numeric.rbs +23 -0
- data/sig/sketchup/animation.rbs +8 -0
- data/sig/sketchup/app_observer.rbs +11 -0
- data/sig/sketchup/arc_curve.rbs +14 -0
- data/sig/sketchup/attribute_dictionaries.rbs +11 -0
- data/sig/sketchup/attribute_dictionary.rbs +18 -0
- data/sig/sketchup/axes.rbs +13 -0
- data/sig/sketchup/behavior.rbs +19 -0
- data/sig/sketchup/camera.rbs +33 -0
- data/sig/sketchup/classification_schema.rbs +8 -0
- data/sig/sketchup/classifications.rbs +12 -0
- data/sig/sketchup/color.rbs +22 -0
- data/sig/sketchup/component_definition.rbs +43 -0
- data/sig/sketchup/component_instance.rbs +32 -0
- data/sig/sketchup/console.rbs +8 -0
- data/sig/sketchup/construction_line.rbs +17 -0
- data/sig/sketchup/construction_point.rbs +5 -0
- data/sig/sketchup/curve.rbs +13 -0
- data/sig/sketchup/definition_list.rbs +26 -0
- data/sig/sketchup/definition_observer.rbs +6 -0
- data/sig/sketchup/definitions_observer.rbs +8 -0
- data/sig/sketchup/dimension.rbs +18 -0
- data/sig/sketchup/dimension_linear.rbs +24 -0
- data/sig/sketchup/dimension_observer.rbs +5 -0
- data/sig/sketchup/dimension_radial.rbs +9 -0
- data/sig/sketchup/drawingelement.rbs +18 -0
- data/sig/sketchup/edge.rbs +24 -0
- data/sig/sketchup/edge_use.rbs +13 -0
- data/sig/sketchup/entities.rbs +61 -0
- data/sig/sketchup/entities_builder.rbs +15 -0
- data/sig/sketchup/entities_observer.rbs +9 -0
- data/sig/sketchup/entity.rbs +21 -0
- data/sig/sketchup/entity_observer.rbs +6 -0
- data/sig/sketchup/environment.rbs +25 -0
- data/sig/sketchup/environments.rbs +18 -0
- data/sig/sketchup/environments_observer.rbs +8 -0
- data/sig/sketchup/extensions_manager.rbs +11 -0
- data/sig/sketchup/face.rbs +44 -0
- data/sig/sketchup/frame_change_observer.rbs +5 -0
- data/sig/sketchup/group.rbs +38 -0
- data/sig/sketchup/http/request.rbs +17 -0
- data/sig/sketchup/http/response.rbs +7 -0
- data/sig/sketchup/http.rbs +27 -0
- data/sig/sketchup/image.rbs +23 -0
- data/sig/sketchup/image_rep.rbs +17 -0
- data/sig/sketchup/importer.rbs +14 -0
- data/sig/sketchup/input_point.rbs +25 -0
- data/sig/sketchup/instance_observer.rbs +6 -0
- data/sig/sketchup/instance_path.rbs +20 -0
- data/sig/sketchup/layer.rbs +20 -0
- data/sig/sketchup/layer_folder.rbs +26 -0
- data/sig/sketchup/layers.rbs +30 -0
- data/sig/sketchup/layers_observer.rbs +13 -0
- data/sig/sketchup/licensing/extension_license.rbs +8 -0
- data/sig/sketchup/licensing.rbs +15 -0
- data/sig/sketchup/line_style.rbs +5 -0
- data/sig/sketchup/line_styles.rbs +13 -0
- data/sig/sketchup/load_handler.rbs +8 -0
- data/sig/sketchup/loop.rbs +10 -0
- data/sig/sketchup/material.rbs +74 -0
- data/sig/sketchup/materials.rbs +22 -0
- data/sig/sketchup/materials_observer.rbs +10 -0
- data/sig/sketchup/menu.rbs +9 -0
- data/sig/sketchup/model.rbs +105 -0
- data/sig/sketchup/model_observer.rbs +23 -0
- data/sig/sketchup/options_manager.rbs +12 -0
- data/sig/sketchup/options_provider.rbs +23 -0
- data/sig/sketchup/options_provider_observer.rbs +5 -0
- data/sig/sketchup/overlay.rbs +21 -0
- data/sig/sketchup/overlays_manager.rbs +10 -0
- data/sig/sketchup/page.rbs +55 -0
- data/sig/sketchup/pages.rbs +25 -0
- data/sig/sketchup/pages_observer.rbs +7 -0
- data/sig/sketchup/pick_helper.rbs +28 -0
- data/sig/sketchup/regional_settings.rbs +7 -0
- data/sig/sketchup/rendering_options.rbs +89 -0
- data/sig/sketchup/rendering_options_observer.rbs +5 -0
- data/sig/sketchup/section_plane.rbs +12 -0
- data/sig/sketchup/selection.rbs +31 -0
- data/sig/sketchup/selection_observer.rbs +8 -0
- data/sig/sketchup/set.rbs +15 -0
- data/sig/sketchup/shadow_info.rbs +18 -0
- data/sig/sketchup/shadow_info_observer.rbs +5 -0
- data/sig/sketchup/skp.rbs +5 -0
- data/sig/sketchup/snap.rbs +10 -0
- data/sig/sketchup/style.rbs +9 -0
- data/sig/sketchup/styles.rbs +21 -0
- data/sig/sketchup/text.rbs +22 -0
- data/sig/sketchup/texture.rbs +14 -0
- data/sig/sketchup/texture_writer.rbs +14 -0
- data/sig/sketchup/tool.rbs +45 -0
- data/sig/sketchup/tools.rbs +14 -0
- data/sig/sketchup/tools_observer.rbs +6 -0
- data/sig/sketchup/uv_helper.rbs +6 -0
- data/sig/sketchup/vertex.rbs +11 -0
- data/sig/sketchup/view.rbs +87 -0
- data/sig/sketchup/view_observer.rbs +6 -0
- data/sig/sketchup.rbs +137 -0
- data/sig/sketchup_extension.rbs +23 -0
- data/sig/string.rbs +5 -0
- data/sig/ui/command.rbs +20 -0
- data/sig/ui/html_dialog.rbs +29 -0
- data/sig/ui/notification.rbs +16 -0
- data/sig/ui/toolbar.rbs +18 -0
- data/sig/ui/web_dialog.rbs +38 -0
- data/sig/ui.rbs +66 -0
- metadata +204 -287
- data/ext/attribute_dictionaries.h +0 -8
- data/ext/attribute_dictionary.h +0 -8
- data/ext/behavior.h +0 -8
- data/ext/color.h +0 -8
- data/ext/component_definition.h +0 -8
- data/ext/component_instance.h +0 -8
- data/ext/definition_list.h +0 -8
- data/ext/drawing_element.h +0 -8
- data/ext/entities.h +0 -8
- data/ext/entity.h +0 -8
- data/ext/material.h +0 -8
- data/ext/materials.h +0 -8
- data/ext/model.h +0 -8
- data/ext/not_implemented.c +0 -88
- data/ext/not_implemented.h +0 -20
- data/ext/sketchup.h +0 -9
- data/ext/texture.h +0 -8
- data/ext/typed_value.c +0 -84
- data/ext/typed_value.h +0 -11
- data/ext/utils.h +0 -111
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Frameworks/libCommonGeometry.dylib +0 -0
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Frameworks/libCommonGeoutils.dylib +0 -0
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Frameworks/libCommonImage.dylib +0 -4
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Frameworks/libCommonPreferences.dylib +0 -0
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Frameworks/libCommonUnits.dylib +0 -0
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Frameworks/libCommonUtils.dylib +0 -0
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Frameworks/libCommonZip.dylib +0 -0
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/application/application.h +0 -36
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/application/model.h +0 -59
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/application/overlay.h +0 -262
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/application/ruby_api.h +0 -118
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/color.h +0 -107
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/common.h +0 -178
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/defs.h +0 -19
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/extension_license.h +0 -70
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/geometry/bounding_box.h +0 -34
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/geometry/plane3d.h +0 -153
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/geometry/point2d.h +0 -96
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/geometry/point3d.h +0 -98
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/geometry/ray3d.h +0 -64
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/geometry/transformation.h +0 -321
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/geometry/transformation2d.h +0 -163
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/geometry/vector2d.h +0 -235
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/geometry/vector3d.h +0 -285
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/geometry.h +0 -154
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/import_export/modelexporterplugin.h +0 -165
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/import_export/modelimporterplugin.h +0 -187
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/import_export/pluginprogresscallback.h +0 -84
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/initialize.h +0 -43
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/length_formatter.h +0 -424
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/arccurve.h +0 -244
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/arrow_type.h +0 -17
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/attribute_dictionary.h +0 -161
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/axes.h +0 -242
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/camera.h +0 -398
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/classification_attribute.h +0 -89
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/classification_info.h +0 -125
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/classifications.h +0 -86
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/component_definition.h +0 -629
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/component_definition_snap_to_behavior_private.h +0 -46
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/component_instance.h +0 -344
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/curve.h +0 -143
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/defs.h +0 -147
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/dimension.h +0 -224
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/dimension_linear.h +0 -421
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/dimension_radial.h +0 -194
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/dimension_style.h +0 -253
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/drawing_element.h +0 -198
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/dynamic_component_attribute.h +0 -92
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/dynamic_component_info.h +0 -70
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/edge.h +0 -271
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/edge_use.h +0 -214
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/entities.h +0 -879
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/entity.h +0 -189
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/entity_list.h +0 -80
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/entity_list_iterator.h +0 -90
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/environment.h +0 -382
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/environments.h +0 -133
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/face.h +0 -702
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/font.h +0 -138
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/geometry.h +0 -20
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/geometry_input.h +0 -695
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/group.h +0 -245
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/guide_line.h +0 -155
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/guide_point.h +0 -153
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/image.h +0 -289
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/image_rep.h +0 -275
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/instancepath.h +0 -266
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/layer.h +0 -265
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/layer_folder.h +0 -301
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/line_style.h +0 -211
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/line_styles.h +0 -81
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/location.h +0 -65
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/loop.h +0 -182
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/material.h +0 -797
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/mesh_helper.h +0 -187
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/model.h +0 -1826
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/model_entity_type_private.h +0 -44
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/model_version.h +0 -49
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/opening.h +0 -72
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/options_manager.h +0 -79
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/options_provider.h +0 -166
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/polyline3d.h +0 -140
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/rendering_options.h +0 -180
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/scene.h +0 -1016
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/schema.h +0 -56
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/schema_type.h +0 -26
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/section_plane.h +0 -212
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/selection.h +0 -156
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/shadow_info.h +0 -147
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/skp.h +0 -45
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/snap.h +0 -183
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/space.h +0 -26
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/style.h +0 -303
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/styles.h +0 -192
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/text.h +0 -392
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/texture.h +0 -380
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/texture_writer.h +0 -280
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/typed_value.h +0 -390
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/uv_helper.h +0 -79
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/model/vertex.h +0 -154
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/sketchup.h +0 -125
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/sketchup_info.h +0 -65
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/slapi.h +0 -16
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/transformation.h +0 -16
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/unicodestring.h +0 -239
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Headers/utils/math_helpers.h +0 -124
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/Resources/Info.plist +0 -50
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/SketchUpAPI +0 -0
- data/sketchup-sdk-mac/SketchUpAPI.framework/Versions/A/_CodeSignature/CodeResources +0 -891
- data/sketchup-sdk-win/binaries/layout/x64/LayOutAPI.dll +0 -0
- data/sketchup-sdk-win/binaries/layout/x64/LayOutAPI.lib +0 -0
- data/sketchup-sdk-win/binaries/layout/x64/LayOutControllers.dll +0 -0
- data/sketchup-sdk-win/binaries/layout/x64/LayOutModel.dll +0 -0
- data/sketchup-sdk-win/binaries/layout/x64/LayOutRTF.dll +0 -0
- data/sketchup-sdk-win/binaries/layout/x64/LayOutUtils.dll +0 -0
- data/sketchup-sdk-win/binaries/layout/x64/LayOutView.dll +0 -4
- data/sketchup-sdk-win/binaries/layout/x64/SketchUpCommonPreferences.dll +0 -0
- data/sketchup-sdk-win/binaries/layout/x64/SketchUpViewerAPI.dll +0 -0
- data/sketchup-sdk-win/binaries/layout/x64/SketchUpViewerAPI.lib +0 -0
- data/sketchup-sdk-win/binaries/layout/x64/pdflib.dll +0 -0
- data/sketchup-sdk-win/binaries/sketchup/x64/SketchUpAPI.dll +0 -0
- data/sketchup-sdk-win/binaries/sketchup/x64/SketchUpAPI.lib +0 -0
- data/sketchup-sdk-win/binaries/sketchup/x64/SketchUpCommonPreferences.dll +0 -0
- data/sketchup-sdk-win/binaries/sketchup/x64/sketchup.lib +0 -0
- data/sketchup-sdk-win/headers/LayOutAPI/application/application.h +0 -117
- data/sketchup-sdk-win/headers/LayOutAPI/common.h +0 -22
- data/sketchup-sdk-win/headers/LayOutAPI/geometry/geometry.h +0 -78
- data/sketchup-sdk-win/headers/LayOutAPI/initialize.h +0 -36
- data/sketchup-sdk-win/headers/LayOutAPI/layout.h +0 -49
- data/sketchup-sdk-win/headers/LayOutAPI/model/angulardimension.h +0 -468
- data/sketchup-sdk-win/headers/LayOutAPI/model/autotextdefinition.h +0 -569
- data/sketchup-sdk-win/headers/LayOutAPI/model/autotextdefinitionlist.h +0 -79
- data/sketchup-sdk-win/headers/LayOutAPI/model/connectionpoint.h +0 -107
- data/sketchup-sdk-win/headers/LayOutAPI/model/defs.h +0 -42
- data/sketchup-sdk-win/headers/LayOutAPI/model/dictionary.h +0 -120
- data/sketchup-sdk-win/headers/LayOutAPI/model/document.h +0 -937
- data/sketchup-sdk-win/headers/LayOutAPI/model/documentexportoptions.h +0 -78
- data/sketchup-sdk-win/headers/LayOutAPI/model/ellipse.h +0 -78
- data/sketchup-sdk-win/headers/LayOutAPI/model/entity.h +0 -402
- data/sketchup-sdk-win/headers/LayOutAPI/model/entityiterator.h +0 -49
- data/sketchup-sdk-win/headers/LayOutAPI/model/entitylist.h +0 -114
- data/sketchup-sdk-win/headers/LayOutAPI/model/formattedtext.h +0 -397
- data/sketchup-sdk-win/headers/LayOutAPI/model/grid.h +0 -251
- data/sketchup-sdk-win/headers/LayOutAPI/model/group.h +0 -244
- data/sketchup-sdk-win/headers/LayOutAPI/model/image.h +0 -146
- data/sketchup-sdk-win/headers/LayOutAPI/model/imagerep.h +0 -109
- data/sketchup-sdk-win/headers/LayOutAPI/model/label.h +0 -332
- data/sketchup-sdk-win/headers/LayOutAPI/model/layer.h +0 -207
- data/sketchup-sdk-win/headers/LayOutAPI/model/layerinstance.h +0 -117
- data/sketchup-sdk-win/headers/LayOutAPI/model/layerlist.h +0 -69
- data/sketchup-sdk-win/headers/LayOutAPI/model/lineardimension.h +0 -508
- data/sketchup-sdk-win/headers/LayOutAPI/model/page.h +0 -331
- data/sketchup-sdk-win/headers/LayOutAPI/model/pageinfo.h +0 -372
- data/sketchup-sdk-win/headers/LayOutAPI/model/pagelist.h +0 -81
- data/sketchup-sdk-win/headers/LayOutAPI/model/path.h +0 -464
- data/sketchup-sdk-win/headers/LayOutAPI/model/rectangle.h +0 -240
- data/sketchup-sdk-win/headers/LayOutAPI/model/referenceentity.h +0 -120
- data/sketchup-sdk-win/headers/LayOutAPI/model/sketchupmodel.h +0 -681
- data/sketchup-sdk-win/headers/LayOutAPI/model/style.h +0 -1116
- data/sketchup-sdk-win/headers/LayOutAPI/model/table.h +0 -472
- data/sketchup-sdk-win/headers/LayOutAPI/model/typed_value.h +0 -180
- data/sketchup-sdk-win/headers/SketchUpAPI/application/application.h +0 -36
- data/sketchup-sdk-win/headers/SketchUpAPI/application/model.h +0 -59
- data/sketchup-sdk-win/headers/SketchUpAPI/application/overlay.h +0 -262
- data/sketchup-sdk-win/headers/SketchUpAPI/application/ruby_api.h +0 -118
- data/sketchup-sdk-win/headers/SketchUpAPI/color.h +0 -107
- data/sketchup-sdk-win/headers/SketchUpAPI/common.h +0 -178
- data/sketchup-sdk-win/headers/SketchUpAPI/defs.h +0 -19
- data/sketchup-sdk-win/headers/SketchUpAPI/extension_license.h +0 -70
- data/sketchup-sdk-win/headers/SketchUpAPI/geometry/bounding_box.h +0 -34
- data/sketchup-sdk-win/headers/SketchUpAPI/geometry/plane3d.h +0 -153
- data/sketchup-sdk-win/headers/SketchUpAPI/geometry/point2d.h +0 -96
- data/sketchup-sdk-win/headers/SketchUpAPI/geometry/point3d.h +0 -98
- data/sketchup-sdk-win/headers/SketchUpAPI/geometry/ray3d.h +0 -64
- data/sketchup-sdk-win/headers/SketchUpAPI/geometry/transformation.h +0 -321
- data/sketchup-sdk-win/headers/SketchUpAPI/geometry/transformation2d.h +0 -163
- data/sketchup-sdk-win/headers/SketchUpAPI/geometry/vector2d.h +0 -235
- data/sketchup-sdk-win/headers/SketchUpAPI/geometry/vector3d.h +0 -285
- data/sketchup-sdk-win/headers/SketchUpAPI/geometry.h +0 -154
- data/sketchup-sdk-win/headers/SketchUpAPI/import_export/modelexporterplugin.h +0 -165
- data/sketchup-sdk-win/headers/SketchUpAPI/import_export/modelimporterplugin.h +0 -187
- data/sketchup-sdk-win/headers/SketchUpAPI/import_export/pluginprogresscallback.h +0 -84
- data/sketchup-sdk-win/headers/SketchUpAPI/initialize.h +0 -43
- data/sketchup-sdk-win/headers/SketchUpAPI/length_formatter.h +0 -424
- data/sketchup-sdk-win/headers/SketchUpAPI/model/arccurve.h +0 -244
- data/sketchup-sdk-win/headers/SketchUpAPI/model/arrow_type.h +0 -17
- data/sketchup-sdk-win/headers/SketchUpAPI/model/attribute_dictionary.h +0 -161
- data/sketchup-sdk-win/headers/SketchUpAPI/model/axes.h +0 -242
- data/sketchup-sdk-win/headers/SketchUpAPI/model/camera.h +0 -398
- data/sketchup-sdk-win/headers/SketchUpAPI/model/classification_attribute.h +0 -89
- data/sketchup-sdk-win/headers/SketchUpAPI/model/classification_info.h +0 -125
- data/sketchup-sdk-win/headers/SketchUpAPI/model/classifications.h +0 -86
- data/sketchup-sdk-win/headers/SketchUpAPI/model/component_definition.h +0 -629
- data/sketchup-sdk-win/headers/SketchUpAPI/model/component_definition_snap_to_behavior_private.h +0 -46
- data/sketchup-sdk-win/headers/SketchUpAPI/model/component_instance.h +0 -344
- data/sketchup-sdk-win/headers/SketchUpAPI/model/curve.h +0 -143
- data/sketchup-sdk-win/headers/SketchUpAPI/model/defs.h +0 -147
- data/sketchup-sdk-win/headers/SketchUpAPI/model/dimension.h +0 -224
- data/sketchup-sdk-win/headers/SketchUpAPI/model/dimension_linear.h +0 -421
- data/sketchup-sdk-win/headers/SketchUpAPI/model/dimension_radial.h +0 -194
- data/sketchup-sdk-win/headers/SketchUpAPI/model/dimension_style.h +0 -253
- data/sketchup-sdk-win/headers/SketchUpAPI/model/drawing_element.h +0 -198
- data/sketchup-sdk-win/headers/SketchUpAPI/model/dynamic_component_attribute.h +0 -92
- data/sketchup-sdk-win/headers/SketchUpAPI/model/dynamic_component_info.h +0 -70
- data/sketchup-sdk-win/headers/SketchUpAPI/model/edge.h +0 -271
- data/sketchup-sdk-win/headers/SketchUpAPI/model/edge_use.h +0 -214
- data/sketchup-sdk-win/headers/SketchUpAPI/model/entities.h +0 -879
- data/sketchup-sdk-win/headers/SketchUpAPI/model/entity.h +0 -189
- data/sketchup-sdk-win/headers/SketchUpAPI/model/entity_list.h +0 -80
- data/sketchup-sdk-win/headers/SketchUpAPI/model/entity_list_iterator.h +0 -90
- data/sketchup-sdk-win/headers/SketchUpAPI/model/environment.h +0 -382
- data/sketchup-sdk-win/headers/SketchUpAPI/model/environments.h +0 -133
- data/sketchup-sdk-win/headers/SketchUpAPI/model/face.h +0 -702
- data/sketchup-sdk-win/headers/SketchUpAPI/model/font.h +0 -138
- data/sketchup-sdk-win/headers/SketchUpAPI/model/geometry.h +0 -20
- data/sketchup-sdk-win/headers/SketchUpAPI/model/geometry_input.h +0 -695
- data/sketchup-sdk-win/headers/SketchUpAPI/model/group.h +0 -245
- data/sketchup-sdk-win/headers/SketchUpAPI/model/guide_line.h +0 -155
- data/sketchup-sdk-win/headers/SketchUpAPI/model/guide_point.h +0 -153
- data/sketchup-sdk-win/headers/SketchUpAPI/model/image.h +0 -289
- data/sketchup-sdk-win/headers/SketchUpAPI/model/image_rep.h +0 -275
- data/sketchup-sdk-win/headers/SketchUpAPI/model/instancepath.h +0 -266
- data/sketchup-sdk-win/headers/SketchUpAPI/model/layer.h +0 -265
- data/sketchup-sdk-win/headers/SketchUpAPI/model/layer_folder.h +0 -301
- data/sketchup-sdk-win/headers/SketchUpAPI/model/line_style.h +0 -211
- data/sketchup-sdk-win/headers/SketchUpAPI/model/line_styles.h +0 -81
- data/sketchup-sdk-win/headers/SketchUpAPI/model/location.h +0 -65
- data/sketchup-sdk-win/headers/SketchUpAPI/model/loop.h +0 -182
- data/sketchup-sdk-win/headers/SketchUpAPI/model/material.h +0 -797
- data/sketchup-sdk-win/headers/SketchUpAPI/model/mesh_helper.h +0 -187
- data/sketchup-sdk-win/headers/SketchUpAPI/model/model.h +0 -1826
- data/sketchup-sdk-win/headers/SketchUpAPI/model/model_entity_type_private.h +0 -44
- data/sketchup-sdk-win/headers/SketchUpAPI/model/model_version.h +0 -49
- data/sketchup-sdk-win/headers/SketchUpAPI/model/opening.h +0 -72
- data/sketchup-sdk-win/headers/SketchUpAPI/model/options_manager.h +0 -79
- data/sketchup-sdk-win/headers/SketchUpAPI/model/options_provider.h +0 -166
- data/sketchup-sdk-win/headers/SketchUpAPI/model/polyline3d.h +0 -140
- data/sketchup-sdk-win/headers/SketchUpAPI/model/rendering_options.h +0 -180
- data/sketchup-sdk-win/headers/SketchUpAPI/model/scene.h +0 -1016
- data/sketchup-sdk-win/headers/SketchUpAPI/model/schema.h +0 -56
- data/sketchup-sdk-win/headers/SketchUpAPI/model/schema_type.h +0 -26
- data/sketchup-sdk-win/headers/SketchUpAPI/model/section_plane.h +0 -212
- data/sketchup-sdk-win/headers/SketchUpAPI/model/selection.h +0 -156
- data/sketchup-sdk-win/headers/SketchUpAPI/model/shadow_info.h +0 -147
- data/sketchup-sdk-win/headers/SketchUpAPI/model/skp.h +0 -45
- data/sketchup-sdk-win/headers/SketchUpAPI/model/snap.h +0 -183
- data/sketchup-sdk-win/headers/SketchUpAPI/model/space.h +0 -26
- data/sketchup-sdk-win/headers/SketchUpAPI/model/style.h +0 -303
- data/sketchup-sdk-win/headers/SketchUpAPI/model/styles.h +0 -192
- data/sketchup-sdk-win/headers/SketchUpAPI/model/text.h +0 -392
- data/sketchup-sdk-win/headers/SketchUpAPI/model/texture.h +0 -380
- data/sketchup-sdk-win/headers/SketchUpAPI/model/texture_writer.h +0 -280
- data/sketchup-sdk-win/headers/SketchUpAPI/model/typed_value.h +0 -390
- data/sketchup-sdk-win/headers/SketchUpAPI/model/uv_helper.h +0 -79
- data/sketchup-sdk-win/headers/SketchUpAPI/model/vertex.h +0 -154
- data/sketchup-sdk-win/headers/SketchUpAPI/sketchup.h +0 -125
- data/sketchup-sdk-win/headers/SketchUpAPI/sketchup_info.h +0 -65
- data/sketchup-sdk-win/headers/SketchUpAPI/slapi.h +0 -16
- data/sketchup-sdk-win/headers/SketchUpAPI/transformation.h +0 -16
- data/sketchup-sdk-win/headers/SketchUpAPI/unicodestring.h +0 -239
- data/sketchup-sdk-win/headers/SketchUpAPI/utils/math_helpers.h +0 -124
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
#include <scriptup.h>
|
|
2
|
+
|
|
3
|
+
// Wraps the target entities. Geometry is added immediately, so it isn't merged.
|
|
4
|
+
#define VALID "__valid"
|
|
5
|
+
|
|
6
|
+
static VALUE builder_valid_p(VALUE self)
|
|
7
|
+
{
|
|
8
|
+
return BOOL2RB(RTEST(rb_attr_get(self, (rb_intern)(VALID))));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
static VALUE builder_entities_obj(VALUE self)
|
|
12
|
+
{
|
|
13
|
+
if (!RTEST(builder_valid_p(self)))
|
|
14
|
+
rb_raise(rb_eRuntimeError, "the builder is no longer valid");
|
|
15
|
+
return su_entities_new(SU_REF(SUEntitiesRef, self));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static VALUE builder_entities(VALUE self)
|
|
19
|
+
{
|
|
20
|
+
return builder_entities_obj(self);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static VALUE builder_add_edge(int argc, VALUE* argv, VALUE self)
|
|
24
|
+
{
|
|
25
|
+
VALUE entities = builder_entities_obj(self);
|
|
26
|
+
VALUE points = argc == 1 ? argv[0] : rb_ary_new_from_values(argc, argv);
|
|
27
|
+
Check_Type(points, T_ARRAY);
|
|
28
|
+
if (RARRAY_LEN(points) != 2)
|
|
29
|
+
rb_raise(rb_eArgError, "expected 2 points");
|
|
30
|
+
return rb_funcall(entities, (rb_intern)("add_line"), 2, RARRAY_AREF(points, 0), RARRAY_AREF(points, 1));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
static VALUE builder_add_edges(int argc, VALUE* argv, VALUE self)
|
|
34
|
+
{
|
|
35
|
+
return rb_funcallv(builder_entities_obj(self), (rb_intern)("add_edges"), argc, argv);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
static void loop_points(VALUE points, struct SUPoint3D** out, long* count)
|
|
39
|
+
{
|
|
40
|
+
Check_Type(points, T_ARRAY);
|
|
41
|
+
*count = RARRAY_LEN(points);
|
|
42
|
+
if (*count < 3)
|
|
43
|
+
rb_raise(rb_eArgError, "a loop needs at least 3 points");
|
|
44
|
+
*out = ALLOC_N(struct SUPoint3D, *count);
|
|
45
|
+
for (long i = 0; i < *count; i++)
|
|
46
|
+
(*out)[i] = su_to_point3d_like(RARRAY_AREF(points, i));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static VALUE builder_add_face(int argc, VALUE* argv, VALUE self)
|
|
50
|
+
{
|
|
51
|
+
VALUE positional;
|
|
52
|
+
VALUE options;
|
|
53
|
+
rb_scan_args(argc, argv, "*:", &positional, &options);
|
|
54
|
+
SUEntitiesRef entities = SU_REF(SUEntitiesRef, builder_entities_obj(self));
|
|
55
|
+
VALUE outer = RARRAY_LEN(positional) == 1 && RB_TYPE_P(RARRAY_AREF(positional, 0), T_ARRAY) &&
|
|
56
|
+
!rb_obj_is_kind_of(rb_ary_entry(RARRAY_AREF(positional, 0), 0), rb_cNumeric)
|
|
57
|
+
? RARRAY_AREF(positional, 0) : positional;
|
|
58
|
+
VALUE holes = Qnil;
|
|
59
|
+
if (!NIL_P(options))
|
|
60
|
+
{
|
|
61
|
+
ID ids[1] = {(rb_intern)("holes")};
|
|
62
|
+
VALUE values[1];
|
|
63
|
+
rb_get_kwargs(options, ids, 0, 1, values);
|
|
64
|
+
holes = values[0] == Qundef ? Qnil : values[0];
|
|
65
|
+
}
|
|
66
|
+
struct SUPoint3D* points;
|
|
67
|
+
long count;
|
|
68
|
+
loop_points(outer, &points, &count);
|
|
69
|
+
SUFaceRef face = SU_INVALID;
|
|
70
|
+
enum SUResult result = SUFaceCreateSimple(&face, points, (size_t)count);
|
|
71
|
+
xfree(points);
|
|
72
|
+
if (result != SU_ERROR_NONE)
|
|
73
|
+
rb_raise(rb_eArgError, "points are not planar or don't form a valid face");
|
|
74
|
+
if (!NIL_P(holes))
|
|
75
|
+
{
|
|
76
|
+
Check_Type(holes, T_ARRAY);
|
|
77
|
+
for (long h = 0; h < RARRAY_LEN(holes); h++)
|
|
78
|
+
{
|
|
79
|
+
struct SUPoint3D* hole;
|
|
80
|
+
long hole_count;
|
|
81
|
+
loop_points(RARRAY_AREF(holes, h), &hole, &hole_count);
|
|
82
|
+
SULoopInputRef loop = SU_INVALID;
|
|
83
|
+
SULoopInputCreate(&loop);
|
|
84
|
+
for (long i = 0; i < hole_count; i++)
|
|
85
|
+
SULoopInputAddVertexIndex(loop, (size_t)i);
|
|
86
|
+
result = SUFaceAddInnerLoop(face, hole, &loop);
|
|
87
|
+
xfree(hole);
|
|
88
|
+
if (result != SU_ERROR_NONE)
|
|
89
|
+
rb_raise(rb_eArgError, "invalid hole");
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
SUEntitiesAddFaces(entities, 1, &face);
|
|
93
|
+
return su_wrap(cFace, face.ptr);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
static VALUE builder_vertex_at(VALUE self, VALUE position)
|
|
97
|
+
{
|
|
98
|
+
struct SUPoint3D p = su_to_point3d(position);
|
|
99
|
+
VALUE edges = rb_funcall(rb_funcall(builder_entities_obj(self), (rb_intern)("grep"), 1, cEdge), (rb_intern)("to_a"), 0);
|
|
100
|
+
for (long i = 0; i < RARRAY_LEN(edges); i++)
|
|
101
|
+
{
|
|
102
|
+
VALUE vertices = rb_funcall(RARRAY_AREF(edges, i), (rb_intern)("vertices"), 0);
|
|
103
|
+
for (long j = 0; j < RARRAY_LEN(vertices); j++)
|
|
104
|
+
{
|
|
105
|
+
struct SUPoint3D v = su_to_point3d_like(RARRAY_AREF(vertices, j));
|
|
106
|
+
bool equal = false;
|
|
107
|
+
SUPoint3DGetEqual(&v, &p, &equal);
|
|
108
|
+
if (equal)
|
|
109
|
+
return RARRAY_AREF(vertices, j);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return Qnil;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
static VALUE builder_invalidate(VALUE builder)
|
|
116
|
+
{
|
|
117
|
+
rb_ivar_set(builder, (rb_intern)(VALID), Qfalse);
|
|
118
|
+
return Qnil;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
static VALUE builder_yield(VALUE builder)
|
|
122
|
+
{
|
|
123
|
+
return rb_yield(builder);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Entities#build: yields a builder that is only valid inside the block.
|
|
127
|
+
static VALUE entities_build(VALUE entities)
|
|
128
|
+
{
|
|
129
|
+
VALUE builder = su_wrap(cEntitiesBuilder, DATA_PTR(entities));
|
|
130
|
+
rb_ivar_set(builder, (rb_intern)(VALID), Qtrue);
|
|
131
|
+
rb_ensure(builder_yield, builder, builder_invalidate, builder);
|
|
132
|
+
return Qnil;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
void Init_entities_builder(void)
|
|
136
|
+
{
|
|
137
|
+
rb_undef_method(rb_singleton_class(cEntitiesBuilder), "new");
|
|
138
|
+
rb_define_method(cEntitiesBuilder, "valid?", builder_valid_p, 0);
|
|
139
|
+
rb_define_method(cEntitiesBuilder, "entities", builder_entities, 0);
|
|
140
|
+
rb_define_method(cEntitiesBuilder, "add_edge", builder_add_edge, -1);
|
|
141
|
+
rb_define_method(cEntitiesBuilder, "add_edges", builder_add_edges, -1);
|
|
142
|
+
rb_define_method(cEntitiesBuilder, "add_face", builder_add_face, -1);
|
|
143
|
+
rb_define_method(cEntitiesBuilder, "vertex_at", builder_vertex_at, 1);
|
|
144
|
+
rb_define_method(cEntities, "build", entities_build, 0);
|
|
145
|
+
}
|
data/ext/entity.c
CHANGED
|
@@ -1,262 +1,222 @@
|
|
|
1
|
-
#include <
|
|
2
|
-
#include <entity.h>
|
|
3
|
-
#include <SketchUpAPI/sketchup.h>
|
|
4
|
-
#include <utils.h>
|
|
1
|
+
#include <scriptup.h>
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
{
|
|
16
|
-
SUEntityRef entity = {DATA_PTR(self)};
|
|
17
|
-
int32_t entityId = 0;
|
|
18
|
-
SUEntityGetID(entity, &entityId);
|
|
19
|
-
return LONG2NUM(entityId);
|
|
20
|
-
}
|
|
3
|
+
#define REF_TYPE_NAMES(X) \
|
|
4
|
+
X(AttributeDictionary) X(Camera) X(ComponentDefinition) X(ComponentInstance) X(Curve) X(Edge) X(EdgeUse) \
|
|
5
|
+
X(Entities) X(Face) X(Group) X(Image) X(Layer) X(Location) X(Loop) X(MeshHelper) X(Material) X(Model) \
|
|
6
|
+
X(Polyline3D) X(Scene) X(Texture) X(TextureWriter) X(TypedValue) X(UVHelper) X(Vertex) X(RenderingOptions) \
|
|
7
|
+
X(GuidePoint) X(GuideLine) X(Schema) X(SchemaType) X(ShadowInfo) X(Axes) X(ArcCurve) X(SectionPlane) \
|
|
8
|
+
X(DynamicComponentInfo) X(DynamicComponentAttribute) X(Style) X(Styles) X(ImageRep) X(InstancePath) X(Font) \
|
|
9
|
+
X(Dimension) X(DimensionLinear) X(DimensionRadial) X(DimensionStyle) X(Text) X(EntityList) \
|
|
10
|
+
X(EntityListIterator) X(DrawingElement) X(Entity) X(LengthFormatter) X(LineStyle) X(LineStyleManager) \
|
|
11
|
+
X(Selection) X(LayerFolder) X(Environment) X(Environments) X(Snap)
|
|
21
12
|
|
|
22
|
-
static
|
|
13
|
+
static const char* ref_type_name(enum SURefType type)
|
|
23
14
|
{
|
|
24
|
-
|
|
25
|
-
switch (SUEntityGetType(entity))
|
|
15
|
+
switch (type)
|
|
26
16
|
{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
case SURefType_ComponentDefinition: return rb_str_new2("ComponentDefinition");
|
|
31
|
-
case SURefType_ComponentInstance: return rb_str_new2("ComponentInstance");
|
|
32
|
-
case SURefType_Curve: return rb_str_new2("Curve");
|
|
33
|
-
case SURefType_Edge: return rb_str_new2("Edge");
|
|
34
|
-
case SURefType_EdgeUse: return rb_str_new2("EdgeUse");
|
|
35
|
-
case SURefType_Entities: return rb_str_new2("Entities");
|
|
36
|
-
case SURefType_Face: return rb_str_new2("Face");
|
|
37
|
-
case SURefType_Group: return rb_str_new2("Group");
|
|
38
|
-
case SURefType_Image: return rb_str_new2("Image");
|
|
39
|
-
case SURefType_Layer: return rb_str_new2("Layer");
|
|
40
|
-
case SURefType_Location: return rb_str_new2("Location");
|
|
41
|
-
case SURefType_Loop: return rb_str_new2("Loop");
|
|
42
|
-
case SURefType_MeshHelper: return rb_str_new2("MeshHelper");
|
|
43
|
-
case SURefType_Material: return rb_str_new2("Material");
|
|
44
|
-
case SURefType_Model: return rb_str_new2("Model");
|
|
45
|
-
case SURefType_Polyline3D: return rb_str_new2("Polyline3D");
|
|
46
|
-
case SURefType_Scene: return rb_str_new2("Scene");
|
|
47
|
-
case SURefType_Texture: return rb_str_new2("Texture");
|
|
48
|
-
case SURefType_TextureWriter: return rb_str_new2("TextureWriter");
|
|
49
|
-
case SURefType_TypedValue: return rb_str_new2("TypedValue");
|
|
50
|
-
case SURefType_UVHelper: return rb_str_new2("UVHelper");
|
|
51
|
-
case SURefType_Vertex: return rb_str_new2("Vertex");
|
|
52
|
-
case SURefType_RenderingOptions: return rb_str_new2("RenderingOptions");
|
|
53
|
-
case SURefType_GuidePoint: return rb_str_new2("GuidePoint");
|
|
54
|
-
case SURefType_GuideLine: return rb_str_new2("GuideLine");
|
|
55
|
-
case SURefType_Schema: return rb_str_new2("Schema");
|
|
56
|
-
case SURefType_SchemaType: return rb_str_new2("SchemaType");
|
|
57
|
-
case SURefType_ShadowInfo: return rb_str_new2("ShadowInfo");
|
|
58
|
-
case SURefType_Axes: return rb_str_new2("Axes");
|
|
59
|
-
case SURefType_ArcCurve: return rb_str_new2("ArcCurve");
|
|
60
|
-
case SURefType_SectionPlane: return rb_str_new2("SectionPlane");
|
|
61
|
-
case SURefType_DynamicComponentInfo: return rb_str_new2("DynamicComponentInfo");
|
|
62
|
-
case SURefType_DynamicComponentAttribute: return rb_str_new2("DynamicComponentAttribute");
|
|
63
|
-
case SURefType_Style: return rb_str_new2("Style");
|
|
64
|
-
case SURefType_Styles: return rb_str_new2("Styles");
|
|
65
|
-
case SURefType_ImageRep: return rb_str_new2("ImageRep");
|
|
66
|
-
case SURefType_InstancePath: return rb_str_new2("InstancePath");
|
|
67
|
-
case SURefType_Font: return rb_str_new2("Font");
|
|
68
|
-
case SURefType_Dimension: return rb_str_new2("Dimension");
|
|
69
|
-
case SURefType_DimensionLinear: return rb_str_new2("DimensionLinear");
|
|
70
|
-
case SURefType_DimensionRadial: return rb_str_new2("DimensionRadial");
|
|
71
|
-
case SURefType_DimensionStyle: return rb_str_new2("DimensionStyle");
|
|
72
|
-
case SURefType_Text: return rb_str_new2("Text");
|
|
73
|
-
case SURefType_EntityList: return rb_str_new2("EntityList");
|
|
74
|
-
case SURefType_EntityListIterator: return rb_str_new2("EntityListIterator");
|
|
75
|
-
case SURefType_DrawingElement: return rb_str_new2("DrawingElement");
|
|
76
|
-
case SURefType_Entity: return rb_str_new2("Entity");
|
|
77
|
-
case SURefType_LengthFormatter: return rb_str_new2("LengthFormatter");
|
|
78
|
-
case SURefType_LineStyle: return rb_str_new2("LineStyle");
|
|
79
|
-
case SURefType_LineStyleManager: return rb_str_new2("LineStyleManager");
|
|
80
|
-
case SURefType_Selection: return rb_str_new2("Selection");
|
|
81
|
-
case SURefType_LayerFolder: return rb_str_new2("LayerFolder");
|
|
82
|
-
case SURefType_Environment: return rb_str_new2("Environment");
|
|
83
|
-
case SURefType_Environments: return rb_str_new2("Environments");
|
|
84
|
-
case SURefType_Snap: return rb_str_new2("Snap");
|
|
17
|
+
#define REF_TYPE_CASE(name) case SURefType_##name: return #name;
|
|
18
|
+
REF_TYPE_NAMES(REF_TYPE_CASE)
|
|
19
|
+
default: return "Unknown";
|
|
85
20
|
}
|
|
86
21
|
}
|
|
87
22
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
23
|
+
DEFINE_GETTER(entity_persistent_id, SUEntityRef, SUEntityGetPersistentID, int64_t, 0, LL2NUM)
|
|
24
|
+
DEFINE_GETTER(entity_entityID, SUEntityRef, SUEntityGetID, int32_t, 0, INT2NUM)
|
|
25
|
+
DEFINE_REF_GETTER(entity_model, SUEntityRef, SUEntityGetModel, SUModelRef, cModel)
|
|
26
|
+
DEFINE_REF_LIST(entity_dictionary_list, SUEntityRef, SUEntityGetNumAttributeDictionaries,
|
|
27
|
+
SUEntityGetAttributeDictionaries, SUAttributeDictionaryRef, cAttributeDictionary)
|
|
28
|
+
|
|
29
|
+
static VALUE entity_typename(VALUE self)
|
|
30
|
+
{
|
|
31
|
+
return rb_str_new_cstr(ref_type_name(SUEntityGetType(SU_REF(SUEntityRef, self))));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static const struct { enum SURefType type; VALUE* klass; } entity_classes[] = {
|
|
35
|
+
{SURefType_ArcCurve, &cArcCurve},
|
|
36
|
+
{SURefType_AttributeDictionary, &cAttributeDictionary},
|
|
37
|
+
{SURefType_Axes, &cAxes},
|
|
38
|
+
{SURefType_Curve, &cCurve},
|
|
39
|
+
{SURefType_EdgeUse, &cEdgeUse},
|
|
40
|
+
{SURefType_Loop, &cLoop},
|
|
41
|
+
{SURefType_Vertex, &cVertex},
|
|
42
|
+
{SURefType_ComponentDefinition, &cComponentDefinition},
|
|
43
|
+
{SURefType_ComponentInstance, &cComponentInstance},
|
|
44
|
+
{SURefType_Dimension, &cDimension},
|
|
45
|
+
{SURefType_DimensionLinear, &cDimension},
|
|
46
|
+
{SURefType_DimensionRadial, &cDimension},
|
|
47
|
+
{SURefType_Edge, &cEdge},
|
|
48
|
+
{SURefType_Face, &cFace},
|
|
49
|
+
{SURefType_Group, &cGroup},
|
|
50
|
+
{SURefType_GuideLine, &cConstructionLine},
|
|
51
|
+
{SURefType_GuidePoint, &cConstructionPoint},
|
|
52
|
+
{SURefType_Image, &cImage},
|
|
53
|
+
{SURefType_Layer, &cLayer},
|
|
54
|
+
{SURefType_LayerFolder, &cLayerFolder},
|
|
55
|
+
{SURefType_LineStyle, &cLineStyle},
|
|
56
|
+
{SURefType_Material, &cMaterial},
|
|
57
|
+
{SURefType_Scene, &cPage},
|
|
58
|
+
{SURefType_RenderingOptions, &cRenderingOptions},
|
|
59
|
+
{SURefType_ShadowInfo, &cShadowInfo},
|
|
60
|
+
{SURefType_Style, &cStyle},
|
|
61
|
+
{SURefType_Styles, &cStyles},
|
|
62
|
+
{SURefType_Environment, &cEnvironment},
|
|
63
|
+
{SURefType_Environments, &cEnvironments},
|
|
64
|
+
{SURefType_SectionPlane, &cSectionPlane},
|
|
65
|
+
{SURefType_Text, &cText},
|
|
66
|
+
{SURefType_Texture, &cTexture},
|
|
67
|
+
};
|
|
103
68
|
|
|
104
|
-
|
|
69
|
+
// Wraps an entity as the Ruby class matching its runtime type.
|
|
70
|
+
VALUE su_wrap_entity(SUEntityRef entity)
|
|
105
71
|
{
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
return RTEST(result) ? Qtrue : Qfalse;
|
|
72
|
+
if (SUIsInvalid(entity))
|
|
73
|
+
return Qnil;
|
|
74
|
+
enum SURefType type = SUEntityGetType(entity);
|
|
75
|
+
for (size_t i = 0; i < sizeof(entity_classes) / sizeof(entity_classes[0]); i++)
|
|
76
|
+
if (entity_classes[i].type == type)
|
|
77
|
+
return su_wrap(*entity_classes[i].klass, entity.ptr);
|
|
78
|
+
return su_wrap(cEntity, entity.ptr);
|
|
115
79
|
}
|
|
116
80
|
|
|
117
|
-
|
|
118
|
-
#pragma clang diagnostic ignored "-Wcompound-token-split-by-macro"
|
|
119
|
-
#pragma clang diagnostic ignored "-Wunused-but-set-variable"
|
|
120
|
-
static VALUE Sketchup_Entity_add_observer(VALUE self, VALUE observer)
|
|
81
|
+
static VALUE entity_parent(VALUE self)
|
|
121
82
|
{
|
|
122
|
-
|
|
123
|
-
if (
|
|
83
|
+
SUEntityRef entity = SU_REF(SUEntityRef, self);
|
|
84
|
+
if (SUEntityGetType(entity) == SURefType_ComponentDefinition)
|
|
124
85
|
{
|
|
125
|
-
|
|
86
|
+
SUModelRef model = SU_INVALID;
|
|
87
|
+
SUEntityGetModel(entity, &model);
|
|
88
|
+
return su_wrap_or_nil(cDefinitionList, model.ptr);
|
|
126
89
|
}
|
|
127
|
-
|
|
128
|
-
{
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
return
|
|
90
|
+
SUEntitiesRef entities = SU_INVALID;
|
|
91
|
+
struct SUEntitiesParent parent = {SU_INVALID, SU_INVALID};
|
|
92
|
+
if (SUEntityGetParentEntities(entity, &entities) != SU_ERROR_NONE || SUEntitiesGetParent(entities, &parent) != SU_ERROR_NONE)
|
|
93
|
+
return Qnil;
|
|
94
|
+
if (SUIsValid(parent.definition))
|
|
95
|
+
return su_wrap(cComponentDefinition, parent.definition.ptr);
|
|
96
|
+
return su_wrap_or_nil(cModel, parent.model.ptr);
|
|
134
97
|
}
|
|
135
|
-
#pragma clang diagnostic pop
|
|
136
98
|
|
|
137
|
-
|
|
99
|
+
// Entities are equal when they wrap the same ref or share an entity ID (refs aren't unique on every platform).
|
|
100
|
+
static int32_t entity_id(VALUE self)
|
|
138
101
|
{
|
|
139
|
-
|
|
102
|
+
int32_t id = 0;
|
|
103
|
+
SUEntityGetID(SU_REF(SUEntityRef, self), &id);
|
|
104
|
+
return id;
|
|
140
105
|
}
|
|
141
106
|
|
|
142
|
-
static VALUE
|
|
107
|
+
static VALUE entity_eq(VALUE self, VALUE other)
|
|
143
108
|
{
|
|
144
|
-
|
|
145
|
-
|
|
109
|
+
if (!rb_obj_is_kind_of(other, cEntity))
|
|
110
|
+
return Qfalse;
|
|
111
|
+
if (DATA_PTR(self) == DATA_PTR(other))
|
|
112
|
+
return Qtrue;
|
|
113
|
+
int32_t id = entity_id(self);
|
|
114
|
+
return BOOL2RB(id != 0 && id == entity_id(other) && rb_obj_class(self) == rb_obj_class(other));
|
|
146
115
|
}
|
|
147
116
|
|
|
148
|
-
|
|
117
|
+
static VALUE entity_hash(VALUE self)
|
|
149
118
|
{
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
119
|
+
int32_t id = entity_id(self);
|
|
120
|
+
VALUE key = id != 0 ? INT2NUM(id) : ULL2NUM((unsigned long long)(uintptr_t)DATA_PTR(self));
|
|
121
|
+
return rb_funcall(key, (rb_intern)("hash"), 0);
|
|
122
|
+
}
|
|
154
123
|
|
|
155
|
-
|
|
124
|
+
static VALUE entity_attribute_dictionaries(VALUE self)
|
|
156
125
|
{
|
|
157
|
-
|
|
158
|
-
GETSTRING(SUAttributeDictionaryGetName, dictionary, output);
|
|
159
|
-
if (strcmp(StringValuePtr(output), StringValuePtr(attribute_dictionary_struct->key)) == 0)
|
|
160
|
-
attribute_dictionary_struct->dictionary = dictionary;
|
|
126
|
+
return su_wrap(cAttributeDictionaries, DATA_PTR(self));
|
|
161
127
|
}
|
|
162
128
|
|
|
163
|
-
static VALUE
|
|
129
|
+
static VALUE entity_find_dictionary(VALUE self, VALUE name)
|
|
164
130
|
{
|
|
165
|
-
|
|
166
|
-
return Qnil;
|
|
167
|
-
if (rb_obj_is_kind_of(self, rb_path2class(SKETCHUP_DEFINITIONLIST)))
|
|
168
|
-
return Qnil;
|
|
169
|
-
SUEntityRef entity = {DATA_PTR(self)};
|
|
170
|
-
struct AttributeDictionaryIterationContext attribute_dictionary_struct = {argv[0], SU_INVALID};
|
|
171
|
-
FOREACH(SUEntityGetNumAttributeDictionaries, SUEntityGetAttributeDictionaries, SUAttributeDictionaryRef, entity, Sketchup_Entity_attribute_dictionary_Iterator, &attribute_dictionary_struct);
|
|
172
|
-
if (SUIsInvalid(attribute_dictionary_struct.dictionary) && argc > 1 && argv[1])
|
|
173
|
-
{
|
|
174
|
-
SUAttributeDictionaryCreate(&attribute_dictionary_struct.dictionary, StringValuePtr(argv[0]));
|
|
175
|
-
SUEntityAddAttributeDictionary(entity, attribute_dictionary_struct.dictionary);
|
|
176
|
-
return Data_Wrap_Struct(rb_path2class(SKETCHUP_ATTRIBUTEDICTIONARY), 0, 0, attribute_dictionary_struct.dictionary.ptr);
|
|
177
|
-
}
|
|
178
|
-
else if(SUIsValid(attribute_dictionary_struct.dictionary))
|
|
179
|
-
return Data_Wrap_Struct(rb_path2class(SKETCHUP_ATTRIBUTEDICTIONARY), 0, 0, attribute_dictionary_struct.dictionary.ptr);
|
|
180
|
-
else
|
|
181
|
-
return Qnil;
|
|
131
|
+
return su_find_by(entity_dictionary_list(SU_REF(SUEntityRef, self)), "name", name);
|
|
182
132
|
}
|
|
183
133
|
|
|
184
|
-
static VALUE
|
|
134
|
+
static VALUE entity_attribute_dictionary(int argc, VALUE* argv, VALUE self)
|
|
185
135
|
{
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
{
|
|
193
|
-
if (strcmp(StringValuePtr(argv[0]), "SU_InstanceSet") == 0 || strcmp(StringValuePtr(argv[0]), "SU_DefinitionSet") == 0)
|
|
194
|
-
rb_raise(rb_eArgError, "Cannot delete internal");
|
|
136
|
+
VALUE name;
|
|
137
|
+
VALUE create;
|
|
138
|
+
rb_scan_args(argc, argv, "11", &name, &create);
|
|
139
|
+
StringValue(name);
|
|
140
|
+
if (rb_obj_is_kind_of(self, cMaterials) || rb_obj_is_kind_of(self, cDefinitionList))
|
|
141
|
+
return Qnil;
|
|
195
142
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
if (SUIsValid(attribute_dictionary_struct.dictionary))
|
|
199
|
-
{
|
|
200
|
-
SUAttributeDictionaryRelease(&attribute_dictionary_struct.dictionary);
|
|
201
|
-
return Qtrue;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
else if (argc > 1)
|
|
143
|
+
VALUE dictionary = entity_find_dictionary(self, name);
|
|
144
|
+
if (NIL_P(dictionary) && RTEST(create))
|
|
205
145
|
{
|
|
206
|
-
|
|
146
|
+
SUAttributeDictionaryRef created = SU_INVALID;
|
|
147
|
+
SUAttributeDictionaryCreate(&created, StringValueCStr(name));
|
|
148
|
+
SUEntityAddAttributeDictionary(SU_REF(SUEntityRef, self), created);
|
|
149
|
+
dictionary = su_wrap(cAttributeDictionary, created.ptr);
|
|
207
150
|
}
|
|
208
|
-
return
|
|
151
|
+
return dictionary;
|
|
209
152
|
}
|
|
210
153
|
|
|
211
|
-
static VALUE
|
|
154
|
+
static VALUE entity_delete_attribute(int argc, VALUE* argv, VALUE self)
|
|
212
155
|
{
|
|
213
|
-
|
|
214
|
-
|
|
156
|
+
VALUE name;
|
|
157
|
+
VALUE key;
|
|
158
|
+
rb_scan_args(argc, argv, "11", &name, &key);
|
|
159
|
+
const char* name_ptr = StringValueCStr(name);
|
|
160
|
+
if (strcmp(name_ptr, "SU_InstanceSet") == 0 || strcmp(name_ptr, "SU_DefinitionSet") == 0)
|
|
161
|
+
rb_raise(rb_eArgError, "Cannot delete internal");
|
|
162
|
+
if (!NIL_P(key))
|
|
163
|
+
rb_raise(rb_eNotImpError, "the C API cannot delete a single attribute key");
|
|
164
|
+
|
|
165
|
+
VALUE dictionary = entity_find_dictionary(self, name);
|
|
166
|
+
if (NIL_P(dictionary))
|
|
167
|
+
return Qfalse;
|
|
168
|
+
SUAttributeDictionaryRef ref = SU_REF(SUAttributeDictionaryRef, dictionary);
|
|
169
|
+
SUAttributeDictionaryRelease(&ref);
|
|
170
|
+
return Qtrue;
|
|
215
171
|
}
|
|
216
172
|
|
|
217
|
-
static VALUE
|
|
173
|
+
static VALUE entity_valid_p(VALUE self)
|
|
218
174
|
{
|
|
219
|
-
|
|
220
|
-
return SUIsValid(entity) ? Qtrue : Qfalse;
|
|
175
|
+
return BOOL2RB(DATA_PTR(self) != NULL);
|
|
221
176
|
}
|
|
222
177
|
|
|
223
|
-
static VALUE
|
|
178
|
+
static VALUE entity_deleted_p(VALUE self)
|
|
224
179
|
{
|
|
225
|
-
|
|
226
|
-
struct AttributeDictionaryIterationContext attribute_dictionary_struct = {argv[0], SU_INVALID};
|
|
227
|
-
FOREACH(SUEntityGetNumAttributeDictionaries, SUEntityGetAttributeDictionaries, SUAttributeDictionaryRef, entity, Sketchup_Entity_attribute_dictionary_Iterator, &attribute_dictionary_struct);
|
|
228
|
-
// use Sketchup_AttributeDictionary_get
|
|
229
|
-
return Qnil;
|
|
230
|
-
|
|
180
|
+
return BOOL2RB(DATA_PTR(self) == NULL);
|
|
231
181
|
}
|
|
232
182
|
|
|
233
|
-
static VALUE
|
|
183
|
+
static VALUE entity_get_attribute(int argc, VALUE* argv, VALUE self)
|
|
234
184
|
{
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
185
|
+
VALUE name;
|
|
186
|
+
VALUE key;
|
|
187
|
+
VALUE default_value;
|
|
188
|
+
rb_scan_args(argc, argv, "21", &name, &key, &default_value);
|
|
189
|
+
StringValue(key);
|
|
190
|
+
VALUE dictionary = entity_find_dictionary(self, name);
|
|
191
|
+
VALUE value = NIL_P(dictionary) ? Qnil : rb_funcall(dictionary, (rb_intern)("[]"), 1, key);
|
|
192
|
+
return NIL_P(value) ? default_value : value;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
static VALUE entity_set_attribute(VALUE self, VALUE name, VALUE key, VALUE value)
|
|
196
|
+
{
|
|
197
|
+
VALUE args[2] = {name, Qtrue};
|
|
198
|
+
VALUE dictionary = entity_attribute_dictionary(2, args, self);
|
|
199
|
+
if (NIL_P(dictionary))
|
|
200
|
+
rb_raise(rb_eArgError, "cannot set attributes on %"PRIsVALUE, rb_obj_class(self));
|
|
201
|
+
rb_funcall(dictionary, (rb_intern)("[]="), 2, key, value);
|
|
202
|
+
return value;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
void Init_entity(void)
|
|
206
|
+
{
|
|
207
|
+
rb_define_method(cEntity, "persistent_id", entity_persistent_id, 0);
|
|
208
|
+
rb_define_method(cEntity, "entityID", entity_entityID, 0);
|
|
209
|
+
rb_define_method(cEntity, "typename", entity_typename, 0);
|
|
210
|
+
rb_define_method(cEntity, "parent", entity_parent, 0);
|
|
211
|
+
rb_define_method(cEntity, "model", entity_model, 0);
|
|
212
|
+
rb_define_method(cEntity, "==", entity_eq, 1);
|
|
213
|
+
rb_define_method(cEntity, "eql?", entity_eq, 1);
|
|
214
|
+
rb_define_method(cEntity, "hash", entity_hash, 0);
|
|
215
|
+
rb_define_method(cEntity, "attribute_dictionaries", entity_attribute_dictionaries, 0);
|
|
216
|
+
rb_define_method(cEntity, "attribute_dictionary", entity_attribute_dictionary, -1);
|
|
217
|
+
rb_define_method(cEntity, "delete_attribute", entity_delete_attribute, -1);
|
|
218
|
+
rb_define_method(cEntity, "deleted?", entity_deleted_p, 0);
|
|
219
|
+
rb_define_method(cEntity, "valid?", entity_valid_p, 0);
|
|
220
|
+
rb_define_method(cEntity, "get_attribute", entity_get_attribute, -1);
|
|
221
|
+
rb_define_method(cEntity, "set_attribute", entity_set_attribute, 3);
|
|
241
222
|
}
|
|
242
|
-
|
|
243
|
-
VALUE Entity_Init(VALUE Sketchup, VALUE rb_cObject)
|
|
244
|
-
{
|
|
245
|
-
VALUE Sketchup_Entity = rb_define_class_under(Sketchup, ENTITY, rb_cObject);
|
|
246
|
-
rb_undef_alloc_func(Sketchup_Entity);
|
|
247
|
-
rb_define_method(Sketchup_Entity, "persistent_id", Sketchup_Entity_persistentId, 0);
|
|
248
|
-
rb_define_method(Sketchup_Entity, "entityID", Sketchup_Entity_entityId, 0);
|
|
249
|
-
rb_define_method(Sketchup_Entity, "typename", Sketchup_Entity_typename, 0);
|
|
250
|
-
rb_define_method(Sketchup_Entity, "parent", Sketchup_Entity_parent, 0);
|
|
251
|
-
rb_define_method(Sketchup_Entity, "model", Sketchup_Entity_model, 0);
|
|
252
|
-
rb_define_method(Sketchup_Entity, "remove_observer", Sketchup_Entity_remove_observer, 1);
|
|
253
|
-
rb_define_method(Sketchup_Entity, "add_observer", Sketchup_Entity_add_observer, 1);
|
|
254
|
-
rb_define_method(Sketchup_Entity, "attribute_dictionaries", Sketchup_Entity_attribute_dictionaries, 0);
|
|
255
|
-
rb_define_method(Sketchup_Entity, "attribute_dictionary", Sketchup_Entity_attribute_dictionary, -1);
|
|
256
|
-
rb_define_method(Sketchup_Entity, "delete_attribute", Sketchup_Entity_delete_attribute, -1);
|
|
257
|
-
rb_define_method(Sketchup_Entity, "deleted?", Sketchup_Entity_deleted, 0);
|
|
258
|
-
rb_define_method(Sketchup_Entity, "valid?", Sketchup_Entity_valid, 0);
|
|
259
|
-
rb_define_method(Sketchup_Entity, "get_attribute", Sketchup_Entity_get_attribute, -1);
|
|
260
|
-
rb_define_method(Sketchup_Entity, "set_attribute", Sketchup_Entity_set_attribute, -1);
|
|
261
|
-
return Sketchup_Entity;
|
|
262
|
-
}
|