Entity.transform!
-
I have some code which used to use entity.transform!(transformation)
But this no longer works for faces or edges in SU 2014 and SU 2015. I see that I should probably be using
entities.transform_entities(transform, ent1, ent2, ent3)
But, this must have worked once. Did this change in SU 2014?
-
Point3d and Vector3d still have #transform! methods. I don't remember ever finding these for Edges or other Entities, though (and I looked while trying to write my plugins back as far as SU 8).
-
Thanks.
I'll find an old version of SketchUp somewhere and see if it used to work for faces and edges one at a time.
-
@al hart said:
I have some code which used to use entity.transform!(transformation)
No you don't.
Sketchup::Entity
class is rather high level that contains things likeSketchup::Page
andSketchup::Layer
, which cannot be transformed.The
transform!()
immediate instance method has only ever applied to collections of entities, ieSketchup::Group
andSketchup::ComponentInstance
,Array
or array-like classes (such as certain virtual object classes in theGeom
module.)The confusion likely comes from the fact that often people think of
Sketchup::Group
andSketchup::ComponentInstance
instances as entities, because they are descended fromSketchup::Entity
, throughSketchup::Drawingelement
.It helps to think of them more as a "wrapper" class, that contains an entities collection, and other properties, including the all important transformation.
-
@al hart said:
I have some code which used to use entity.transform!(transformation)
But this no longer works for faces or edges in SU 2014 and SU 2015.
But, this must have worked once. Did this change in SU 2014?No - Entity.transform! has never been part of the API. If you ever used this you where using some custom method someone modified the API namespace with.
We've not removed methods from the API and the API docs is the one you should go by in terms of looking up what is part of the API. Anything else is stuff that has been injected. There are the occational debug helper methods that we hooked up, but they are not supported as part of the API.
-
Thanks all.
I guess my routine must have only been applying .transform! to component instances and groups, and somehow faces and edges slipped in.
I was reading a .SKP from the disk and scaling thing in different layers differently, and the disk .skp must have changed so that there was a face at the top level of entities.
-
By the way, if you transform multiple entities it's faster to do it in bulk with Entities.transform_entities or Entities.transform_by_vector. Ditto for erasing and selecting - the performance differences between doing this in bulk is significant.
Whenever you use erase! or transform! etc or any other single entity action within a loop consider the bulk alternatives.
Advertisement