How can I get data of a page?

I want to know how sketchup stores the page info. Is it possible to get the data of a page? I print out all methods of a page, but can’t find hints.

The methods of a page:

[:description, :axes, :use_rendering_options?, :use_rendering_options=, :update, :use_style?, :use_style=, :name, :use_shadow_info=, :use_shadow_info?, :use_camera=, :use_axes?, :use_hidden?, :use_hidden=, :use_hidden_geometry?, :use_hidden_geometry=, :use_hidden_objects?, :use_hidden_objects=, :use_camera?, :use_hidden_layers?, :use_hidden_layers=, :use_axes=, :use_section_planes=, :use_section_planes?, :hidden_entities, :name=, :transition_time=, :transition_time, :style, :camera, :delay_time=, :include_in_animation?, :delay_time, :set_visibility, :set_drawingelement_visibility, :include_in_animation=, :layers, :get_drawingelement_visibility, :description=, :label, :shadow_info, :rendering_options, :attribute_dictionaries, :set_attribute, :get_attribute, :inspect, :to_s, :remove_observer, :valid?, :add_observer, :attribute_dictionary, :parent, :model, :entityID, :typename, :deleted?, :persistent_id, :delete_attribute, :get_attributes, :has_attributes?, :to_json, :instance_variable_set, :instance_variable_defined?, :remove_instance_variable, :instance_of?, :kind_of?, :is_a?, :tap, :instance_variable_get, :public_methods, :instance_variables, :public_method, :define_singleton_method, :singleton_method, :method, :public_send, :extend, :pp, :to_enum, :enum_for, :<=>, :===, :=~, :!~, :eql?, :respond_to?, :freeze, :object_id, :send, :display, :nil?, :class, :hash, :clone, :singleton_class, :itself, :dup, :taint, :yield_self, :untaint, :tainted?, :untrust, :untrusted?, :trust, :frozen?, :methods, :singleton_methods, :protected_methods, :private_methods, :!, :equal?, :instance_eval, :==, :instance_exec, :!=, :id, :send]

What kind of page info or data are you looking for?
What do you want to do with it?
Can you please elaborate more? Maybe you can share a screenshot of Sketchup and mark what you are thinking about…

I am digging it more. I want to get the entities that are visible on a specific page.

Actually I intend to implement the functionality similar to creating dwg: retrieve info of a page and render the image of the page like what layout does.

Is there api to export a page as 2d DWG?

I still not really understand, I do know how to create dwg…

BTW you do not need to “print out” the methods we do have a “nice” documentations:

BTW 2: Would you please edit your profile, because for sure you can not use Ruby API in SketchUp for web.

I’m not sure you can check this:

I guess currently the 3D exportes are exposed only for Ruby API …

You maybe can think about export as picture

EG. There is an old “plugin” for that here:

Thank you very much dezmo. Yes, I am looking for a solution to exporting scenes. Sketch can export 2D graphic. Its ruby API can export scenes as images, but I want the exported result with more information such as size of parts in the images.

The Ruby API can export model as obj format. Is it possible to export pages as 2D format (like DWG) that can be read by human? I want to build further applications on the page information.

( Disclaimer: I’m not native English speaker, so some unintentional mistakes are foreseen… :wink: )

As I told you unfortunately at the moment, only 3D exporters are exposed to the Ruby API.

Moreover the pages (scenes) does not store the information’s of object It is stored in the model. (or in definitions and instance transformation)
The pages are storing a kind of flag which properties (like top level hidden geometry, hidden objects…) of the object or the tags will be stored into the page. The current visibility of the of the “part” is depends of the combination of the object properties and if it is stored or not on the pages.


does not “stored” directly at all. You have to write your own method and “ask” for example vertex position, bounding box corners, edge length or face area… and calculate the size of the questionably “part”.
You must be consider the transformations as well if the “parts” are holding by a components or group definition and which instance of it the current one…

You would need to send the scene pages to LayOut as viewports and export from LayOut.

Thank you very much.

Now I am trying to get details of a model.

model = Sketchup.active_model
entities = model.entities
entities.length # output 21
entities[0].instance_variables # output

Its variables are empty. How can I get the details of a model, an entity, a layer?

By reading the documentation at:
Here, for example, is all documentation about the Entity class:

You will notice that Entity is a base class for more concrete classes such as Edge, Face, Group, ComponentInstance, … (Are you also a SketchUp user btw?) and it will be instances of those concrete classes you will be iterated once you iterate the entries in the Entities instance.
In Ruby, to know what class the instance has you are currently iterating, you call the class method, for example: klass = Sketchup.active_model.entities[0].class. Then you know what the class is of the entity you are currently iterating and you can call concrete methods on it. For example, see the documentation of the Face class here:

1 Like