Jump to content
Developer Wiki and Function Reference Links ×

shapeable PIO's


Hippocode

Recommended Posts

  • Vectorworks, Inc Employee

When you first create a PIO you have the option to choose the type, you need to create a path based or a rectangular type PIO rather than a point PIO. There is no way to change from one type to the other.

With a rectangular PIO you have 2 automatic parameters Height and Width and a control point will allow you to reshape.

Path based PIO allows the user to draw a shape and it is stored in the path group of the PIO so you can access the shape in the script. When the user edits the shape they are editing the path.

Link to comment

Hey,

I tried drawing some lines using a 2d path object with this

I can't change the lines once they are drawn. Does it only work with shapes (rect/circle etc ) or is there someting I forgot in the coding ?

This is the script I used:

PROCEDURE test;
VAR
pathHd,objHd,objrecHd,wHd	:HANDLE;
result					:BOOLEAN;
objName				:STRING;

num_vertices,i			:INTEGER;
seg_angle				:REAL;
dir_vec				:VECTOR;

v1x,v1y,v2x,v2y		:REAL;
t1x,t1y,t2x,t2y,tdx,tdy		:REAL;

BEGIN
{ retrieve plug-in object information }
result:= GetCustomObjectInfo(objName,objHd,objrecHd,wHd);

{ if the plug-in object info was successfully retrieved }
IF result THEN BEGIN

	{ obtain a handle to the path polygon of the object }
	pathHd:= GetCustomObjectPath(objHd);

	{ get the number of vertices in the path }
	num_vertices:= GetVertNum(pathHd);

	{ draw the piping lines and text label }
	FOR i:= 2 TO num_vertices DO BEGIN
		GetPolyPt(pathHd,i,v2x,v2y);
		GetPolyPt(pathHd,i - 1,v1x,v1y);

		{ get the direction vector of a polygon segment }
		dir_vec.x:= v2x - v1x;
		dir_vec.y:= v2y - v1y;

		MoveTo(v1x,v1y);
		LineTo(v2x,v2y);
	END;	
END;
END;
Run(test);

Edited by hippothamus
Link to comment

Yes but that's not what I'm looking for.

The 2d reshape tool lets you change the path but not relative to the background and other objects of the drawing.

When you draw a rectangle/polyline from scratch you get multiple selective points to change position of each segment. That's what I'm trying to get on a custom polygon/polyline.

Edited by hippothamus
Link to comment
  • Vectorworks, Inc Employee

In order to get the interactive reshape the object needs to be event enabled.

After you enable the option in the VS Plug-in editor, the simplest way to do this is to place your existing code in a procedure called "Main" then use the following to call the Main procedure. This will give you reshape and also the ability to have surface operations on the object.

(You will need to declare a few variables and consts.)

kObjXPropSpecialEdit = 3;

kReshapeSpecialEdit = 3;

kObjXIs2DSurfaceEligible = 14;

kObjXPropEditGroup = 1;

kObjXPropEditGroupPath = 2;

kObjOnInitXProperties = 5;

kResetEventID = 3;

BEGIN

vsoGetEventInfo(theEvent, theButton);

CASE theEvent OF

kObjOnInitXProperties:

BEGIN

status:=SetObjPropCharVS(kObjXPropSpecialEdit,Chr(kReshapeSpecialEdit));

status:=SetObjPropVS(kObjXIs2DSurfaceEligible,TRUE);

status:=SetObjPropCharVS(kObjXPropEditGroup,Chr(kObjXPropEditGroupPath));

status:=vsoInsertAllParams;

END;

kResetEventID:

BEGIN

Main;

END;

END;

END;

Link to comment
  • 2 months later...

This worked on all objects with a path.

But I can't get it to work on lets say a lineair object.

Should I create a custom path in it to define the length of the lineair object ? or can the kObjXPropEditGroupPath be changed into something else ?

In order to get the interactive reshape the object needs to be event enabled.

After you enable the option in the VS Plug-in editor, the simplest way to do this is to place your existing code in a procedure called "Main" then use the following to call the Main procedure. This will give you reshape and also the ability to have surface operations on the object.

(You will need to declare a few variables and consts.)

kObjXPropSpecialEdit = 3;

kReshapeSpecialEdit = 3;

kObjXIs2DSurfaceEligible = 14;

kObjXPropEditGroup = 1;

kObjXPropEditGroupPath = 2;

kObjOnInitXProperties = 5;

kResetEventID = 3;

BEGIN

vsoGetEventInfo(theEvent, theButton);

CASE theEvent OF

kObjOnInitXProperties:

BEGIN

status:=SetObjPropCharVS(kObjXPropSpecialEdit,Chr(kReshapeSpecialEdit));

status:=SetObjPropVS(kObjXIs2DSurfaceEligible,TRUE);

status:=SetObjPropCharVS(kObjXPropEditGroup,Chr(kObjXPropEditGroupPath));

status:=vsoInsertAllParams;

END;

kResetEventID:

BEGIN

Main;

END;

END;

END;

Link to comment
A path object is the only type of object that has a valid path that you can edit.

Linear objects will have the insertion point and an end point, moving either point is the only reshape method available.

I still work with vectorworks 2010. It seems that the lineair reshape method doesn't work properly on my version.

My script can be reshaped starting from vw version 2011 :(

Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...