Finding a Component/group axis?
-
Ok, I thought I knew how to do this, but I seem to be unable to figure it out.
Lets say I have a nice ComponentInstance in my model. I want to find the 3d position (x,y,z) where it's axis is set. is that possible?
-
hm... I thought it would be
myInstance.definition.insertion_point
but it seem to only return a vector of (0,0,0)...I know that you can't set the axis via ruby, but I had thought you could read it... hm...
-
I think I just found what I was hoping to find. What I need is in the transformation array. It is position 13 = x, 14 = y and 15 = z. So:
So select a component and run this in the webconsole and it puts the xyz position - hooray!puts Sketchup.active_model.selection[0].transformation.to_a[12] puts Sketchup.active_model.selection[0].transformation.to_a[13] puts Sketchup.active_model.selection[0].transformation.to_a[14]
-
Oh, you responded.
I think the insert point exists because of some functionality that SU has built in to make it so that when you insert a component from the browser, it fixes itself to your cursor based on the last point that you used to move another instance of that component in-model. That is the insertion_point I think. Seems weird its an array. It says it should be a Point3d object.
Chris
-
Ah, yea. That gives the global position even if the instance is nested.
-
@chris fullmer said:
Oh, you responded.
I think the insert point exists because of some functionality that SU has built in to make it so that when you insert a component from the browser, it fixes itself to your cursor based on the last point that you used to move another instance of that component in-model. That is the insertion_point I think. Seems weird its an array. It says it should be a Point3d object.
Chris
Yea, it was a Point3d object. Though, an array [0,0,0] can be used in place of Point3d.
-
tee-hee-he. You said aray, and for some reason my mind though of an array as it defines a vector line. My mind hes been working with normals on quite a few projects I think.
Thanks for the input!
Chris
-
Actually, I think I said it returned a vector... ... ...I'm going to go to bed now. Wires are getting crossed again...
Advertisement