Error Message
-
Sorry guys, it's me again.
Can someone say something about this error message:
'add_instance': Insertion would result in recursive definition
It appears in a rotation command.Thanks
-
Looks like you're attempting to insert the new instance into its own definition.
So instead of inserting the instance into the entities of the definition, insert it into the entities of the model.
-
Well, I know no ruby so a "rural" example: Make a component and while editing it, try to insert the same component inside itself...
-
I'm not sure what do you mean.
So it's better if i'll show you my code,
then you can teach me by reference to the code:` model = Sketchup.active_model
entities = model.active_entities
group = entities.add_group
entities = group.entities#-----------------------------------
Kettensaege kreiern
width_kettensaege = 40 depth_kettensaege = 1 height_kettensaege = 6 color_kettensaege = Sketchup::Color.new(169,169,169) pts = [] pts[0] = [0.5, 0.5, 0.5] pts[1] = [width_kettensaege+0.5, 0.5, 0.5] pts[2] = [width_kettensaege + 0.5, 0.5 + depth_kettensaege, 0.5] pts[3] = [0.5, 0.5 + depth_kettensaege, 0.5] base = entities.add_face pts
create material
mat_kettensaege=model.materials.add("Material_Kettensaege") mat_kettensaege.color=color_kettensaege area = base.area base.back_material = mat_kettensaege base.material = mat_kettensaege base.pushpull(height_kettensaege) kettensaege = my_definition = Sketchup.active_model.definitions[0]
to hide the original object
entities.each { |entity| entity.visible = false }
#----------------------------------
point = Geom::Point3d.new(0,0,0)
vector = [0,0,1]
angle = 1.57079
rotation = Geom::Transformation.rotation point, vector, angle
instance = entities.add_instance kettensaege, rotation # here is the error
#-----------------------------------` -
What is your intention with this line?
kettensaege = my_definition = Sketchup.active_model.definitions[0]
You're making a reference to an arbitrary component definition - which in your case is the definition for the group which you try to add an instance into.
-
angle = 1.57079
I assume you want a 90 degree angle in radians - which you can write as90.degrees
. See theNumeric
class for modifications that SU has done to the base class: http://code.google.com/apis/sketchup/docs/ourdoc/numeric.html -
Thanks to all,
the problem is solved -
Advertisement