comp_example_instancia.rb (425 Bytes)
new_comp_def = Sketchup.active_model.definitions.add(“MyCube”)
points = Array.new ;
points[0] = ORIGIN ;
points[1] = [100, 0 , 0] ;
points[2] = [100, 100, 0] ;
points[3] = [0 , 100, 0] ;
newface = new_comp_def.entities.add_face(points)
newface.reverse! if newface.normal.z < 0
newface.pushpull(100)
trans = Geom::Transformation.new
Sketchup.active_model.active_entities.add_instance(new_comp_def, trans)
instance = Sketchup.active_model.active_entities.add_instance(new_comp_def, trans)
instance.name = "test"
This reinserts the component.
I want to add in the exponent component created
You misunderstood my post. I meant the first line to replace your last line with the sole purpose of capturing the reference to the new instance so you can give it a name in the next line. It wasn’t meant simply to append both lines to your code - which will indeed create a second instance!
now I understand .
Thanks a lot for the help
Slbaumgartner
My native language is portuguese from Brazil because of this the misunderstanding
new_comp_def = Sketchup.active_model.definitions.add(“MyCube”)
points = Array.new ;
points[0] = ORIGIN ;
points[1] = [100, 0 , 0] ;
points[2] = [100, 100, 0] ;
points[3] = [0 , 100, 0] ;
newface = new_comp_def.entities.add_face(points)
newface.reverse! if newface.normal.z < 0
newface.pushpull(100)
trans = Geom::Transformation.new
instance = Sketchup.active_model.definitions
instance = Sketchup.active_model.active_entities.add_instance(new_comp_def, trans)
instance.name = “test”
Not exactly.
You added a frivolous line of code, which I have commented out below:
new_comp_def = Sketchup.active_model.definitions.add("MyCube")
points = Array.new ;
points[0] = ORIGIN ;
points[1] = [100, 0 , 0] ;
points[2] = [100, 100, 0] ;
points[3] = [0 , 100, 0] ;
newface = new_comp_def.entities.add_face(points)
newface.reverse! if newface.normal.z < 0
newface.pushpull(100)
trans = Geom::Transformation.new
# instance = Sketchup.active_model.definitions
instance = Sketchup.active_model.active_entities.add_instance(new_comp_def, trans)
instance.name = "test"
Please put code in between code delimiter lines:
```ruby
# code goes here
```
(The code language can be: ruby, xml,c,javascript,html …)
DanRathbun
How do I add this up in this code?
~ruby
group = entities.add_group face[0].faces[1].all_connected
group.layer = @layer
componente = group.to_component
componente = componente.definition
componente.name = "C#1"
componente.description = "A36"
You must use backtick characters (not # characters!)
The backtick is just above the TAB key. It has the tilde (~) on the key also.
Also, please start another topic thread for a different coding problem.
And, if this one has been answered, mark the post that solved it as the solution.
(Use the icon at the bottom of the post that you think is the soultion.)
I showed you above, let me show you again (for the last time.)
Please put code in BETWEEN code delimiter lines:
```ruby
# code goes here
```
This topic was automatically closed after 91 days. New replies are no longer allowed.