VvierA Posted October 30, 2012 Share Posted October 30, 2012 Hello, let's say I'd like to make a simple rectangle as a plugin object. I'd use rect(0,0,10,-5) to draw it. The insertion point would be automatically the origin of the plugin object (i.e. 0,0). The question ist: How can I change the insertion point of the plugin object. Let's say, I want the insertion point to be in the center of the rectangle. Do I have to change the command to rect(-5,2.5,5,-2.5) or Is it possible to 'move' the insertion point independently, so that I do not have change the position of the rectangle on the internal coordinate system of the plugin object? The aim in the end is certainly to be able to change the insertion point of the plugin object via the object info palette and to have a code as simple as possible to draw the rectangle. VvierA Quote Link to comment
Miguel Barrera Posted October 30, 2012 Share Posted October 30, 2012 Do I have to change the command to rect(-5,2.5,5,-2.5) Yes, to make the center of the rect the insertion point which is always at (0,0) of the plug-in coordinate system. It is the same way as symbols behave. I think the easiest way would be to draw first the object(s) as a group and then move the group relative to the origin at (0,0) Quote Link to comment
Dieter @ DWorks Posted October 30, 2012 Share Posted October 30, 2012 And if you want to move the plug-in itself, you can do that too. Quote Link to comment
VvierA Posted October 30, 2012 Author Share Posted October 30, 2012 I tried this, but it doesn't work. I do not now how to move the newly generated group. Thank you VvierA --- procedure door; VAR ObjectH : HANDLE; BEGIN BEGINGROUP; LINE (0.04,0); ARCBYCENTER (0.04,0,0.805,0,90); MOVE (0.805,0); LINE (0.04,0); ENDGROUP; MOVE3D(2,2,0); END; RUN (door); Quote Link to comment
JBenghiat Posted October 30, 2012 Share Posted October 30, 2012 A few things. If you have a rectangular PIO, there is a clear origin, but identifying the insertion point is less straightforwards, at least to the user. If you do offset the object from its origin, you lose the ability to resize the object via its corners and edges in a logical way. If you have a point PIO, then the insertion origin is more clear. The cleanest way to code this is to define an offsetX and offsetY variable, and add them to every coordinate that you use to draw. Eg. offsetY could be -height/2, 0, or height/2 depending on a top, center, or bottom alignment setting. You should have your script commands work with handles rather than on selected objects. Move() will move selected objects. HMove() will move objects with the specified handle. As PIO code functions on objects within a container, you should use the handle versions of any commands. HTH, Josh Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.