Im struggling with this issue how to transform lines or faces inside a component. The code looks something like this:
model = Sketchup.active_model
ents = model.active_entities
defs = model.definitions
wallcomponent_def = defs.add "YVWall"
wallcomponent_layer1_def = defs.add "YVWall_layer_1"
t = Geom::Transformation.new [0,0,0]
pts1 = 
pts1 = [0,0,0]
pts1 = [x_len,0,0]
pts1 = [x_len,0,z]
pts1 = [0,0,z]
pts1b = 
pts1b = [layer_width,layer_width,0]
pts1b = [x_len-layer_width,layer_width,0]
pts1b = [x_len-layer_width,layer_width,z]
pts1b = [layer_width,layer_width,z]
front_base_line_1 = wallcomponent_layer1_def.entities.add_line pts1,pts1
front_top_line_1 = wallcomponent_layer1_def.entities.add_line pts1,pts1
This is what I have tried which don’t work:
entities_to_transform = 
transform = Geom::Transformation.new([1000,0,0])
Any help is appreciated
You are applying the ‘transform_entities’ to the model.active_entities [aka ‘ents’]
BUT the entities you pass are NOT in that entities collection… but in…
So the transformation will not work !
if you used:
the two newly added edges would transform 1000 inches east along the red-axis - however, perhaps not as you had hoped ??
In your last line,
ents is referencing
model.active_entities but you want to transform the Definition’s entities.
amazing! thanks both of you
FYI: In SketchUp component definitions do not have a layer property, so associating a definition with a layer is pointless. Any instance of any definition, can be associated or re-associated, with any layer at any time, either manually or via code.
The end-goal is something like this:
YVWall # Main Component
| > YVWall_layer_1 # Component, and member of YVWall. Eg bricks
| > YVWall_layer_2 # Component, and member of YVWall. Eg insulation
| > YVWall_layer_3 # Component, and member of YVWall. Eg concrete
In each YVWall_layer_x there will be set an attribute to a face
The confusion arises from your use of the word ‘layer’ in the naming convention…
In SketchUp it’s assigned to an entity and is used to control visibility.
If you substituted another word for ‘layer’, then the confusion would be avoided, e.g.
ok I understand. The word layer is what we would use in my own language about different parts of a wall.
I might well use ‘layer’ too.
But for the avoidance of doubt / confusion, perhaps a non-sketchup sensitive word would be better.