Jump to content
Sign in to follow this  
TiTaNiuM sAMuRai

Path PIO vertices ID

Recommended Posts

Guest

You call GetCustomObjectPath to get a copy of the 2D Polyline or 3D NURBS curve that defines the path. Call GetVertNum to get the number of vertices and then loop for each one calling GetPolyPt.

Here is the script for a sample 2D Path Plug-in Object that draws rectangles at each vertex point.

{}{ Sample2DPathPlugin }{ Sample VectorScript 2D Path Plug-in Object for VectorWorks 9. }{ When the user selects this object's tool on the toolbar, it will allow }{ the user to click several times to specify the vertices of a 2D polyline}{ curve. The curve will be stored within the plug-in object as the "path" }{ and will not be drawn to the screen. The plug-in object can access its }{ path and do whatever is appropriate with it. It can use the path to }{ create other objects along it. If you want the path itself to be }{ visible, then you must duplicate it. }{}{ This object will draw rectangles of increasing size at each vertex of }{ the path. }{}

Procedure Sample2DPathPlugin;

CONST startSize = .25;VAR objName : STRING; objHand : HANDLE; objRecordHand : HANDLE; wallHand : HANDLE; resultStatus : BOOLEAN; hProfileObj : HANDLE; hPathObj : HANDLE; numVerts, i : INTEGER; xPt, yPt : REAL; boxSize : REAL;

Function NewSize(oldSize : REAL) : REAL;{ Computes new box size. }BEGIN NewSize := oldSize * 5 / 4;END;

{ -------------------------- Main program -------------------------- }BEGIN { --------------------------------------- } { Get Regeneration information } { --------------------------------------- }

objName := 'BAD'; objHand := nil; objRecordHand := nil; wallHand := nil; resultStatus := GetCustomObjectInfo(objName, objHand, objRecordHand, wallHand); IF (resultStatus = TRUE) AND (objHand <> NIL) AND (objRecordHand <> NIL) THEN BEGIN boxSize := startSize; hPathObj := GetCustomObjectPath(objHand); IF (hPathObj <> nil) THEN BEGIN numVerts := GetVertNum(hPathObj); FOR i := 1 TO numVerts DO BEGIN GetPolyPt(hPathObj, i, xPt, yPt); Rect(xPt, yPt, xPt+boxSize, yPt+boxSize); boxSize := NewSize(boxSize); END; END ELSE BEGIN { Message('Path handle is nil'); } { Recover from a missing path by creating a default path, } { and calling SetCustomObjectPath() with it. } END;

END;END;Run(Sample2DPathPlugin);

Share this post


Link to post

Samurai ,

Have a look at this path-PIO code sample:

{-----------------------------------} Procedure PolyPathPIO;VAR objHd, pHd, rHd, wHd : HANDLE; objName : STRING; i, n, Vtype : INTEGER; Vx, Vy, Vradius : REAL;BEGIN IF getCustomObjectInfo(objName, objHd, rHd, wHd) THEN BEGIN pHd := getCustomObjectPath(objHd); n := getVertNum(pHd); {ClosePoly;} BEGINPOLY; FOR i:=1 to n do begin GetPolylineVertex(pHd, i, Vx, Vy, Vtype,Vradius); addPoint(Vx,Vy); END; {of FOR base polygon loop} {*}GetPolylineVertex(pHd, 1, Vx, Vy, Vtype, Vradius); {*}addPoint (Vx,Vy); {* goes back to the 1st point - not very elegant a closing procedure - you might get strange behavior without this} ENDPOLY; FOR i:=1 to n do begin GetPolylineVertex(pHd, i, Vx, Vy, Vtype, Vradius); SetPolylineVertex(LNewObj, i, Vx, Vy, Vtype, Vradius, FALSE); END; {of FOR smoothing loop} SetPolylineVertex(LNewObj, i, Vx, Vy, Vtype, Vradius, TRUE); END; {of IF getCustomObjectInfo}END;{-----------------------------------}

I think path-PIOs are not really supposed to have holes on their paths, but I have some code for holes if you want.

Share this post


Link to post

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.

Sign in to follow this  

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×
×
  • Create New...