/
Model.rb
1656 lines (1578 loc) · 51.5 KB
/
Model.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Copyright:: Copyright 2024 Trimble Inc.
# License:: The MIT License (MIT)
# This is the interface to a SketchUp model. The model is the 3D drawing that
# the user is working with, and it serves as the "entry point" for most Ruby
# API interactions. The Sketchup.active_model method gives you a handle to the
# current model, and from there you can use the model-level methods to start
# getting information and making changes.
#
# Constants:
# Product Family
# - Model::ProTrial
# - Model::ProLicensed
# - Model::MakeTrial
# - Model::MakeTrialExpired
#
# @bug Prior to SketchUp 2019.0 this class would yield +TypeError+ for all
# method calls if +#singleton_class+ was called on the model object.
#
# @example
# # Grab a handle to the currently active model (aka the one the user is
# # looking at in SketchUp.)
# model = Sketchup.active_model
#
# # Grab other handles to commonly used collections inside the model.
# entities = model.entities
# layers = model.layers
# materials = model.materials
# component_definitions = model.definitions
# selection = model.selection
#
# # Now that we have our handles, we can start pulling objects and making
# # method calls that are useful.
# first_entity = entities[0]
# UI.messagebox("First thing in your model is a #{first_entity.typename}")
#
# number_materials = materials.length
# UI.messagebox("Your model has #{number_materials} materials.")
#
# new_edge = entities.add_line([0,0,0], [500,500,0])
#
# @version SketchUp 6.0
class Sketchup::Model
# Constants
LOAD_STATUS_SUCCESS = nil # Stub value.
LOAD_STATUS_SUCCESS_MORE_RECENT = nil # Stub value.
Make = nil # Stub value.
MakeTrial = nil # Stub value.
ProLicensed = nil # Stub value.
ProTrial = nil # Stub value.
VERSION_2013 = nil # Stub value.
VERSION_2014 = nil # Stub value.
VERSION_2015 = nil # Stub value.
VERSION_2016 = nil # Stub value.
VERSION_2017 = nil # Stub value.
VERSION_2018 = nil # Stub value.
VERSION_2019 = nil # Stub value.
VERSION_2020 = nil # Stub value.
VERSION_2021 = nil # Stub value.
VERSION_3 = nil # Stub value.
VERSION_4 = nil # Stub value.
VERSION_5 = nil # Stub value.
VERSION_6 = nil # Stub value.
VERSION_7 = nil # Stub value.
VERSION_8 = nil # Stub value.
# Instance Methods
# The {#abort_operation} method aborts the current operation started with the
# start_operation method.
#
# The {#abort_operation} method is normally called from inside of a rescue
# clause to cancel an operation if something goes wrong.
#
# @example
# status = model.abort_operation
#
# @note Never abort a transparent operation. Doing so would abort the operation
# it chains to. Instead, try to clean up and simply commit in order to make
# sure the operation is closed.
#
# @return [Boolean] true if successful, false if unsuccessful
#
# @version SketchUp 6.0
def abort_operation
end
# Returns an {Sketchup::Entities} object which contains
# the entities in the open group or component instance. If no group or
# component is open for editing then this will be the same as {#entities}.
#
# To perform actions upon the current set of entities the user is working with
# then this is the method to use. Entities selected by the user will be a
# subset of the active entities.
#
# @example
# model = Sketchup.active_model
# entities = model.active_entities
# entities.each { |entity| puts "#{entity} (#{entity.class})" }
#
# @return [Sketchup::Entities]
#
# @see #edit_transform
#
# @version SketchUp 6.0
def active_entities
end
# The {#active_layer} method retrieves the active Layer.
#
# The default layer in SketchUp is layer 0.
#
# @example
# model = Sketchup.active_model
# layer = model.active_layer
#
# @return [Sketchup::Layer]
#
# @version SketchUp 6.0
def active_layer
end
# The {#active_layer=} method sets the active {Sketchup::Layer} object.
#
# @example
# model = Sketchup.active_model
# layers = model.layers
# layer = layers.add('My Layer')
# model.active_layer = layer
#
# @param [Sketchup::Layer] layer
# The layer to be set as the active layer.
#
# @return [Sketchup::Layer]
#
# @version SketchUp 6.0
def active_layer=(layer)
end
# Returns an array containing the sequence of entities the user has
# double-clicked on for editing. This allows one to determine whether they are
# in component edit mode and where in the model they are.
#
# For example, if a user has double-clicked into a component to
# edit its geometry, and then double clicked into a sub-group to edit that,
# the active_path might contain:
#
# <code>[<Sketchup::ComponentInstance>, <Sketchup::Group>]</code>
#
# @example
# active_path = Sketchup.active_model.active_path
#
# @return [Array<Sketchup::Drawingelement>, nil] array of entities showing where the user is
# currently editing.
#
# @version SketchUp 7.0
def active_path
end
# The {#active_path=} method is used to open a given instance path for editing.
#
# @example Open an instance
# model = Sketchup.active_model
# instance = model.active_entities.grep(Sketchup::ComponentInstance).first
# instance_path = Sketchup::InstancePath.new([instance])
# model.active_path = instance_path
#
# @example Close all instances
# model = Sketchup.active_model
# model.active_path = nil
#
# @note An instance path can only be opened if the instances are not locked.
# This also include instances of the same component definition that are not
# on the given path. A definition cannot be edited if any of its instances
# are locked.
#
# @note Since changing the active entities in SketchUp also changes what
# coordinate system is used, entities can't be modified in the same operation
# as the active entities changes. The API handles this automatically by
# starting and committing transparent operations as needed.
#
# If the API user tries to do this:
#
# model.start_operation('...', true)
# model.active_entities.add_face(...)
# model.active_path = instance_path
# model.active_entities.add_face(...)
# model.commit_operation
#
# Then SketchUp will automatically break it up to something like to this:
#
# model.start_operation('...', true)
# model.active_entities.add_face(...)
# model.commit_operation
#
# model.start_operation('...', true, false, true)
# model.active_path = instance_path
# model.commit_operation
#
# model.start_operation('...', true, false, true)
# model.active_entities.add_face(...)
# model.commit_operation
#
# For the end user this will be experienced as a single operation.
#
# For the API user the side-effect is multiple transaction notifications to
# {Sketchup::ModelObserver}s.
#
# @param [Sketchup::InstancePath, Array<Sketchup::ComponentInstance, Sketchup::Group>, nil] instance_path
# Passing +nil+ or an empty array will close all open instances.
#
# @raise [ArgumentError] if the instance path is not valid.
#
# @raise [ArgumentError] if the instance path contains locked instances.
#
# @raise [ArgumentError] if the instance path contains instances who's
# siblings are locked.
#
# @raise [ArgumentError] if the instance path contains Live Components.
#
# @return [Sketchup::Model]
#
# @version SketchUp 2020.0
def active_path=(instance_path)
end
# The {#active_view} method returns the active View object for this model.
#
# @example
# model = Sketchup.active_model
# view = model.active_view
#
# @return [Sketchup::View]
#
# @version SketchUp 6.0
def active_view
end
# Add a text note to the Model. The position of the note is given as relative
# window positions between 0 and 1. For example, the following command
# would create a note that start 1/10 of the ways down the screen from the
# upper left corner of the window.
#
# @example
# model = Sketchup.active_model
# # Add a note 1/10 ways down the screen and 1/10 ways right from the
# # upper left corner of model window.
# note = Sketchup.active_model.add_note('Hello World', 0.1, 0.1)
#
# @param [String] note
# A string note.
#
# @param [Numeric] x
# A distance along the x axis between 0 and 1.
#
# @param [Numeric] y
# A distance along the y axis between 0 and 1.
#
# @return [Sketchup::Text] a note object or an exception if it is
# unsuccessful.
#
# @version SketchUp 6.0
def add_note(note, x, y)
end
# The add_observer method is used to add an observer to the current object.
#
# @example
# model = Sketchup.active_model
# observer = Sketchup::ModelObserver.new
# status = model.add_observer(observer)
#
# @param [Object] observer
# An observer.
#
# @return [Boolean] true if successful, false if unsuccessful.
#
# @version SketchUp 6.0
def add_observer(observer)
end
# The {#attribute_dictionaries} method retrieves the AttributeDictionaries
# object that is associated with the Model.
#
# @example
# model = Sketchup.active_model
# dictionaries = model.attribute_dictionaries
# if dictionaries
# # Code to do something if attribute dictionaries exist (usually you
# # parse the array of dictionaries.
# else
# # Code to do something if attribute dictionaries do not exist.
# end
#
# @return [Sketchup::AttributeDictionaries] the AttributeDictionaries
# object associated with the entity, or nil if there are
# no attribute_dictionary objects associated with the
# model. Care must be taken if nil is returned, for
# example: invoking attribute_dictionaries.length will
# throw a NoMethodError exception, not return 0.
#
# @version SketchUp 6.0
def attribute_dictionaries
end
# Returns the Sketchup::AttributeDictionary object that is specified by
# name. If the model does not have an attribute dictionary that
# corresponds to name, returns either nil, or a creates an attribute
# dictionary. If the optional second argument is true, and there is no
# attribute dictionary that corresponds to name, a new attribute
# dictionary is created.
#
# @example
# model = Sketchup.active_model
# create_if_empty = true
# dictionary = model.attribute_dictionary('name', create_if_empty)
#
# @param [String] name
# The name of the dictionary you are attempting to
# retrieve.
#
# @param [Boolean] create
# if set to true an attribute dictionary of the
# given "name" will be created if not found.
#
# @return [Sketchup::AttributeDictionary] an attribute dictionary object if
# successful, nil if unsuccessful
#
# @version SketchUp 6.0
def attribute_dictionary(name, create = false)
end
# The {#axes} method returns the drawing axes for the model.
#
# @example
# # Point for a rectangle.
# points = [
# Geom::Point3d.new( 0, 0, 0),
# Geom::Point3d.new(10, 0, 0),
# Geom::Point3d.new(10, 20, 0),
# Geom::Point3d.new( 0, 20, 0)
# ]
# # Transform the points so they are local to the model axes. Otherwise
# # they would be local to the model origin.
# tr = Sketchup.active_model.axes.transformation
# points.each { |point| point.transform!(tr) }
# Sketchup.active_model.active_entities.add_face(points)
#
# @return [Sketchup::Axes] the axes for the model.
#
# @version SketchUp 2016
def axes
end
# The behavior method retrieves the behavior of the model.
#
# @example
# model = Sketchup.active_model
# behavior = model.behavior
#
# @return [Sketchup::Behavior] behavior object for the model if successful
#
# @version SketchUp 6.0
def behavior
end
# The {#bounds} method is used to retrieve the {Geom::BoundingBox} bounding the
# contents of a {Sketchup::Model}.
#
# @example
# model = Sketchup.active_model
# bounds = model.bounds
#
# @return [Geom::BoundingBox]
#
# @version SketchUp 6.0
def bounds
end
# The {#classifications} method is used to retrieve the Classifications object
# for this model.
#
# @example
# model = Sketchup.active_model
# c = model.classifications
#
# @return [Sketchup::Classifications] a Classifications object.
#
# @version SketchUp 2015
def classifications
end
# The {#close} method is used to close this model. On Mac OS, only the active
# model can be closed. On Windows, since there can be only one document open,
# this method will perform a File/New operation.
#
# @example
# Sketchup.file_new
# model = Sketchup.active_model
# model.close
#
# @note As of SketchUp 2024.0 this method will ensure the next model window
# gets focus if there is one. Before that `Sketchup.active_model` might
# return `nil` after calling this method even though more models where open.
#
# @param [Boolean] ignore_changes
# If `true`, model changes will be
# ignored and save prompts will be suppressed.
# If `false`, changes will not be ignored and save
# prompts will be displayed normally.
#
# @return [nil]
#
# @version SketchUp 2015
def close(ignore_changes = false)
end
# The {#close_active} method is used to close the currently active (open) group
# or component.
#
# @example
# model = Sketchup.active_model
# status = model.close_active
#
# @note Before SketchUp 2014 this method had a bug where it didn't create an
# undo operation and that could lead to corrupted geometry when undo/redo was
# used after invoking this method.
#
# @return [Boolean] true if successful, false if unsuccessful.
#
# @version SketchUp 6.0
def close_active
end
# The commit_operation method commits an operation for undo.
#
# The commit_operation method is normally called at the end of a method to
# commit the operation that the method performs.
#
# @example
# status = model.commit_operation
#
# @return [Boolean] true if successful, false if unsuccessful
#
# @version SketchUp 6.0
def commit_operation
end
# The {#definitions} method retrieves a definition list containing all of the
# component definitions in the model.
#
# @example
# model = Sketchup.active_model
# definitions = model.definitions
#
# @return [Sketchup::DefinitionList]
#
# @version SketchUp 6.0
def definitions
end
# The description method retrieves a description of the model as found in the
# Model Info > Files panel.
#
# The returned description can be empty. The default description for all models
# is empty.
#
# @example
# model = Sketchup.active_model
# description = model.description
#
# @return [String] a description if successful.
#
# @version SketchUp 6.0
def description
end
# The {#description=} method sets the description of the model.
#
# @example
# model = Sketchup.active_model
# description = model.description = "This is a model of a house on the " <<
# "North West Corner of 10th and Dolores Street in Carmel, California"
#
# @param [String] description
# the description string to be set.
#
# @return [String]
#
# @version SketchUp 6.0
def description=(description)
end
# The {#drawing_element_visible?} method reports whether the given drawing
# element in an instance path is visible given the current model options.
#
# @example Traversing every visible entity in the model
# module Example
#
# def self.instance?(entity)
# entity.is_a?(Sketchup::ComponentInstance) || entity.is_a?(Sketchup::Group)
# end
#
# # Walk the visible entities in the model, taking into account
# # "DrawHiddenGeometry" and "DrawHiddenObjects" rendering options.
# def self.walk(entities, transformation = IDENTITY, path = [], &block)
# entities.each { |entity|
# entity_path = path + [entity]
# next unless entity.model.drawing_element_visible?(entity_path)
# block.call(entity, transformation, path)
# if instance?(entity)
# child_entities = entity.definition.entities
# child_transformation = transformation * entity.transformation
# walk(child_entities, child_transformation, entity_path, &block)
# end
# }
# end
#
# end
#
# model = Sketchup.active_model
# Example.walk(model.entities) do |entity, transformation, path|
# # Do something to every visible entity in the model...
# end
#
# @param [Sketchup::InstancePath, Array<Sketchup::Drawingelement>] instance_path
#
# @raise [ArgumentError] if the +instance_path+ is not valid.
#
# @return [Boolean]
#
# @see Sketchup::RenderingOptions
#
# @see Sketchup::Drawingelement#visible?
#
# @see Sketchup::Layer#visible?
#
# @version SketchUp 2020.0
def drawing_element_visible?(instance_path)
end
# Returns the transformation of the current component edit session. If a user
# has double-clicked to edit a component's geometry, this will
# return the transformation of that component, relative to its parent's
# origin. This allows one to correctly calculate "local" transformations of
# a given entity regardless of whether the user is in edit mode.
#
# @example
# Sketchup.active_model.edit_transform
#
# @return [Geom::Transformation] the current edit Transformation
#
# @version SketchUp 7.0
def edit_transform
end
# The {#entities} method returns an {Sketchup::Entities} object containing the
# entities in the root of model.
#
# @example
# model = Sketchup.active_model
# entities = model.entities
#
# @note This does not return a collection of all the entities in the model,
# only the top level node of the model hierarchy. To get to all entities in
# a model you must recursivly traverse the model.
#
# @return [Sketchup::Entities] an Entities object if successful
#
# @version SketchUp 6.0
def entities
end
# The export method is used to export a given file format. It knows which
# format to export based on the file extension you place on the file name.
# For example, a filename of "thing.obj" will export an OBJ file, whereas
# "thing.dae" will export a COLLADA file.
#
# For SketchUp Pro 7.1+, valid extensions include dae, kmz, 3ds, dwg,
# dxf, fbx, obj, wrl, and xsi. SketchUp Free only supports dae and kmz.
#
# Format Support Changes:
# * SketchUp 7.1 added COLLADA (.dae) export capability.
# * SketchUp Pro 2015+ added IFC export capability.
# * SketchUp Pro 2016+ added PDF export capability.
# * SketchUp Pro 2018+ added options for all 3D exporters.
#
# See the {file:pages/exporter_options.md Exporter Options} file for information
# on creating a valid hash for the various exporters.
#
# @example General use
# model = Sketchup.active_model
# show_summary = true
#
# # Export dwg file on a PC, showing a summary when complete.
# status = model.export('c:\my_export.dwg', show_summary)
#
# # Export kmz file on Mac (note the absolute file path), without summary.
# status = model.export('/Library/my_export.kmz')
#
# # Export pdf file on a PC, showing a summary when complete.
# options_hash = { :show_summary => true,
# :output_profile_lines => false,
# :map_fonts => false,
# :model_units => Length::Meter }
# status = model.export('c:/my_export.pdf', options_hash)
#
# # Or for a COLLADA (.dae) file.
# options_hash = { :triangulated_faces => true,
# :doublesided_faces => true,
# :edges => false,
# :author_attribution => false,
# :texture_maps => true,
# :selectionset_only => false,
# :preserve_instancing => true }
# status = model.export('c:/my_export.dae', options_hash)
#
# @example IFC Example
# model = Sketchup.active_model
# # If no IFC types are passed in, then no geometry will be exported.
# options_hash = { :hidden_geometry => true,
# :ifc_mapped_items => true,
# :ifc_types => ['IfcBuilding', 'IfcDoor']}
# status = model.export('c:/my_export.ifc', options_hash)
#
# @overload export(path, show_summary = false)
#
# @param [String] path The name of the file to export.
# @param [Boolean] show_summary Boolean to show summary dialog.
# @return [Boolean]
#
# @overload export(path, options)
#
# @param [String] path The path to save the export at.
# @param [Hash] options
# @return [Boolean]
#
# @raise [ArgumentError] If the file extension is unsupported.
#
# @version SketchUp 6.0
def export(*args)
end
# Finds and returns entities by their entityID or GUID.
#
# GUIDs looked up are only relevant to Group and ComponentInstance as these
# GUIDs are persistent. ComponentDefinition and Model GUIDs are not persistent
# and are not looked up.
#
# When given an array of IDs, an array is returned with a 1:1 mapping to the
# input arguments. This array may contain nil values if some ids were not
# found. You cannot look up a mix of entityIDs and GUIDs in the same call.
#
# @example
# model = Sketchup.active_model
#
# # Look up by entityID.
# entity_id = model.entities.add_line([0,0,0], [9,9,9]).entityID
# entity = model.find_entity_by_id(entity_id)
#
# # Look up by GUID.
# guid = model.entities.add_group.guid
# entity = model.find_entity_by_id(guid)
#
# # Look up multiple.
# entities = model.find_entity_by_id(id1, id2, id3)
# entities = model.find_entity_by_id([id1, id2, id3])
# entities = model.find_entity_by_id(guid1, guid2, guid3)
# entities = model.find_entity_by_id([guid1, guid2, guid3])
#
# @param [Array<Integer, String>] ids_or_array
# Pass either a series of ids or a single array containing
# ids. Ids must either be entityID Integers or GUID
# Strings.
#
# @return [Array<Sketchup::Entity, nil>] Returns an array with Entity objects for each id
# found and nil otherwise. Single Entity or nil when
# called with a single id.
#
# @version SketchUp 2015
def find_entity_by_id(ids_or_array)
end
# Finds and returns entities by their persistent id.
#
# When given an array of IDs, an array is returned with a 1:1 mapping to the
# input arguments. This array may contain `nil` values if some ids were not
# found.
#
# @example
# model = Sketchup.active_model
#
# # Look up by persistent_id.
# pid = model.entities.add_line([0,0,0], [9,9,9]).persistent_id
# entity = model.find_entity_by_persistent_id(pid)
#
# # Look up multiple.
# entities = model.find_entity_by_persistent_id(id1, id2, id3)
# entities = model.find_entity_by_persistent_id([id1, id2, id3])
#
# @example Limit search by scope
# model = Sketchup.active_model
# edge_pid = model.entities.add_line([0,0,0], [9,9,9]).persistent_id
# layer_pid = model.layers.add('Hello World').persistent_id
#
# # Search in all scopes:
# entities = model.find_entity_by_persistent_id(edge_pid, layer_pid)
# # => [#<Sketchup::Edge:0x000002567da4a8f0>, #<Sketchup::Layer:0x000002567da49e50>]
#
# # Search in layer scope:
# entities = model.find_entity_by_persistent_id(edge_pid, layer_pid, layers: true)
# # => [nil, #<Sketchup::Layer:0x000002567da49e50>]
#
# @overload find_entity_by_persistent_id(ids_or_array)
#
# @param [Array<Integer>] ids_or_array Pass either a series of ids or a
# single array containing persistent ids.
#
# @return [Array<Sketchup::Entity, nil>] Returns an array with
# {Sketchup::Entity} objects for each id found and nil otherwise.
#
# @overload find_entity_by_persistent_id(ids_or_array, **scope)
#
# @version SketchUp 2020.2
# @param [Array<Integer>] ids_or_array Pass either a series of ids or a
# single array containing persistent ids.
# @param [Hash<Symbol, Boolean>] scope Limit the scope of the search to the
# given scope categories.
# @option [Boolean] scope :entities Search entities parent to
# {Sketchup::Entities}.
# @option [Boolean] scope :layers Search {Sketchup::Layers} for
# {Sketchup::Layer} entities.
# @option [Boolean] scope :layer_folders Search {Sketchup::Layers} for
# {Sketchup::LayerFolder} entities.
# @option [Boolean] scope :materials Search {Sketchup::Materials} for
# {Sketchup::Material} entities.
# @option [Boolean] scope :pages Search {Sketchup::Pages} for
# {Sketchup::Page} entities.
# @option [Boolean] scope :styles Search {Sketchup::Styles} for
# {Sketchup::Style} entities.
# @option [Boolean] scope :definitions Search {Sketchup::DefinitionList} for
# {Sketchup::ComponentDefinition} entities.
#
# @return [Array<Sketchup::Entity, nil>] Returns an array with
# {Sketchup::Entity} objects for each id found and nil otherwise.
#
# @version SketchUp 2017
def find_entity_by_persistent_id(*args)
end
# This methods determines if the model is georeferenced.
#
# @example
# if model.georeferenced?
# UI.messagebox('This model is georeferenced.')
# else
# UI.messagebox('This model is NOT georeferenced.')
# end
#
# @return [Boolean]
#
# @version SketchUp 7.1
def georeferenced?
end
# The get_attribute method gets the value of an attribute that in the
# AttributeDictionary with the given name. If no value is associated
# with key, or if the model does not have an attribute dictionary
# specified by name, the optional third parameter will be returned.
#
# @example
# model = Sketchup.active_model
# model.set_attribute('testdictionary', 'test', 115)
# value = model.get_attribute('testdictionary', 'test', 42)
#
# @param [String] dictname
# The name of the dictionary containing the value.
#
# @param [String] key
# The key containing the value.
#
# @param [Object] defaultvalue
# default value that will be returned if a
# value does not exist.
#
# @return [Object, nil] the value for a given key in the given
# dictionary if a value exists; the default value if a
# defaultvalue is provided and the value does not exist;
# nil if the value does not exist and no defaultvalue is
# provided.
#
# @version SketchUp 6.0
def get_attribute(dictname, key, defaultvalue = nil)
end
# the get_datum method retrieves the datum, in the form of a string, used in
# UTM conversions.
#
# @example
# model = Sketchup.active_model
# datum = model.get_datum
#
# @return [String] a datum represented as a string if successful.
#
# @version SketchUp 6.0
def get_datum
end
# Returns a value which indicates the product family of the installed SketchUp
# application.
# As of SketchUp 2013, the return values are:
# - +0+ = Unknown
# - +1+ = Pro Trial
# - +2+ = Pro
# - +3+ = Pro Expired
# - +4+ = Make Trial
# - +5+ = Make Expired
# - +6+ = Make
# - +7+ = Pro License Unavailable
#
# The Model class defines some of these values as constants as of SketchUp
# 2016.
#
# @example
# model = Sketchup.active_model
# product_family = model.get_product_family
# if product_family == Sketchup::Model::ProLicensed then
# puts "You are running licensed SketchUp Pro!"
# end
#
# @return [Integer] the product family number.
#
# @version SketchUp 6.0
def get_product_family
end
# The guid method retrieves the globally unique identifier, in the form of a
# string, for the Model. The guid will change after the model is modified and
# saved. The Model guid is stored with the SketchUp file; it will not change if the
# file is moved to another computer.
#
# @example
# model = Sketchup.active_model
# guid = model.guid
#
# @return [String] a globally unique identifier, in the form of a
# string, for the model
#
# @version SketchUp 6.0
def guid
end
# The import method is used to load a file by recognizing the file extension
# and calling appropriate importer.
#
# See {Sketchup::DefinitionList#import} for importing a 3d model file as a
# component definition, without activating the UI for placing an instance.
#
# See the {file:pages/importer_options.md Importer Options} file for information
# on creating a valid hash for the various importers.
#
# @example Import for SketchUp 2017 and older
# model = Sketchup.active_model
# show_summary = true
# status = model.import("filename", show_summary)
#
# @example Import for SketchUp 2018+ and newer
# model = Sketchup.active_model
# options = { :units => "model",
# :merge_coplanar_faces => true,
# :show_summary => true }
# status = model.import("filename", options)
#
# @overload import(path, options)
#
# @param [String] path The input file path.
# @param [Hash] options The options.
# @return [Boolean]
#
# @overload import(path, show_summary = false)
#
# @note This variant is for SketchUp 2017 and earlier.
# @param [String] path The input file path.
# @param [Boolean] show_summary Show the summary dialog.
# @return [Boolean]
#
# @version SketchUp 6.0
def import(*args)
end
# The {#instance_path_from_pid_path} method returns a instance path given a
# string with persistent ids representing the path to the entity.
#
# @example
# points = [
# Geom::Point3d.new( 0, 0, 0),
# Geom::Point3d.new(10, 0, 0),
# Geom::Point3d.new(10, 20, 0),
# Geom::Point3d.new( 0, 20, 0)
# ]
# model = Sketchup.active_model
# entities = model.active_entities
# group = entities.add_group
# face = group.entities.add_face(points)
# pid_path = "#{group.persistent_id}.#{face.persistent_id}"
# # pid_path will look something like this: "658.723"
# instance_path = model.instance_path_from_pid_path(pid_path)
#
# @param [String] pid_path
# a string with persistent ids delimited by period.
#
# @raise [ArgumentError] if a valid instance path cannot be created from the
# given input path string.
#
# @return [Sketchup::InstancePath]
#
# @see Sketchup::InstancePath#persistent_id_path
#
# @version SketchUp 2017
def instance_path_from_pid_path(pid_path)
end
# The latlong_to_point method converts a latitude and longitude to a Point3d
# object in the model. It does not actually work with a LatLong object, but
# operates on a 2-element array. The returned point will always be on the
# ground (z=0).
#
# @example
# # Draw a point in Boulder, Colorado (40.0170N, 105.2830W)
# lnglat_array = [-105.28300, 40.01700]
# model = Sketchup.active_model
# local_point = model.latlong_to_point(lnglat_array)
# model.entities.add_cpoint(local_point)
#
# @param [Array(Numeric, Numeric)] lnglat_array
# A 2-element array containing first the longitude then
# the latitude.
#
# @return [Geom::Point3d] a point3d object if successful, false if
# unsuccessful.
#
# @version SketchUp 6.0
def latlong_to_point(lnglat_array)
end
# The {#layers} method retrieves a collection of all {Sketchup::Layers} objects
# in the model.
#
# @example
# model = Sketchup.active_model
# layers = model.layers
#
# @return [Sketchup::Layers] a Layers object containing a collection of
# layers in the model
#
# @version SketchUp 6.0
def layers
end
# The {#line_styles} method returns the line styles manager.
#
# @example
# line_styles = Sketchup.active_model.line_styles
#
# @return [Sketchup::LineStyles] The line styles manager.
#
# @version SketchUp 2019
def line_styles
end
# This method retrieves an Array of all of the datums recognized by SketchUp.
#
# @example
# model = Sketchup.active_model
# datums = model.list_datums
#
# @return [Array<String>] An Array object containing the datums
# supported by SketchUp
#
# @version SketchUp 6.0
def list_datums
end
# The {#materials} method returns a collection of all of the materials in the
# model.
#
# @example
# model = Sketchup.active_model
# materials = model.materials
#
# @return [Sketchup::Materials]
#
# @version SketchUp 6.0
def materials
end