Not Getting GUIDs of sketchUP active model objects or entities

Hello, I am trying to get GUIDs of individual entities or objects ,so whenever i try to get GUIDs of selected entities from imported or loaded .skp model its working fine .but if I created some geometries like 'circle. rectangle, polygon ’ and try to get GUIDs of these three entities so result found empty.

selection = active_model.selection
 selection.each do |entity|
      guid = entity.guid
      file.write(guid + "\n") unless guid.nil?

here is ruby function i try to get GUID of selected entities

The guid method only for:

Perhaps you can use:
Entity #entityID-instance_method
Entity #persistent_id-instance_method

Since SketchUp is a surface modeler, all circles, arcs, and arbitrary curves, rectangles… are really just edges that are bound together in sequence.


Using Entity#persistent_id is the way to go since v2017.

1 Like

hello @dezmo , @DanRathbun I want one unique id for particular entity and it should be same through out the session also. Is there any id it should be persist in whole session an also with if model was saved.
“Entity#persistent_id” gives me array of persistent id’s with differ respective geometries(like circle,geometry,etc). My concern is i want only one unique id which will be same with geomtery

The persistent id persistent between sessions.
This is a method for Sketchup::Entity.:

This is the base class for all SketchUp entities. Entities are basically anything that can be contained in a model, including Drawingelements such as Edges, SectionPlanes, Groups, etc. and entities that relate to those Drawingelements, such as Loops, Layers, etc.

Keep in mind that the methods below are available on all subclasses. For example, an Edge’s parent class is Drawingelement, and a Drawingelement’s parent class is Entity. Therefore an Edge has all of the methods defined in Drawingelement and Entity.

The Object.is_a? method is the common way of determining what sort of Entity you’re dealing with.

The Sketchup::Curve class is used by SketchUp to unite a series of Edge objects into one conceptual entity. Since SketchUp is a surface modeler, all circles, arcs, and arbitrary curves are really just edges that are bound together in sequence.

The Curve is a subclass of Entity. (So you can get persistent id of curve too)

There is a subclass of Curve called ArcCurve, which is any curve that makes up part of a circle. You can think of ArcCurves as entities that were created with SketchUp’s Arc or Circle drawing tools and Curves as entities that were created with the Freehand drawing tool.

… id is id, geometry is geometry these can not be same.

…otherwise, unfortunately - after a few hours of reading (even tried to translate)…I don’t quite understand what your concern is…sorry, you need to explain more.

1 Like

Hello @dezmo my concern was i want a unique id like GUID for any single individual geometry i drawn on sketchup active model and through out session and after saving that model id also to be constant with them. Or if it is not possible so can i write custom Guid or any unique id on that geometry drawn. If you have any concern let me know

You do not need to be concerned. Use Entity#persistent_id, as we have said multiple times.

1 Like