TiTaNiuM sAMuRai Posted August 21, 2002 Share Posted August 21, 2002 How are the various points along the PIO's path identified? The Vectorscript manual explains rectangular and linear PIO's well, but glances over path type PIO's. Quote Link to comment
Guest Posted August 21, 2002 Share Posted August 21, 2002 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); Quote Link to comment
Guest Posted August 21, 2002 Share Posted August 21, 2002 ...or download the sample plug-in objects from our Website. There is a sample path plug-in object that draws a schematic of a pipe run. http://www.nemetschek.net/support/custom/vscript/example.html Quote Link to comment
TiTaNiuM sAMuRai Posted August 21, 2002 Author Share Posted August 21, 2002 Thanks, Koppi-san! Quote Link to comment
Alexandre Villares Posted August 22, 2002 Share Posted August 22, 2002 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. Quote Link to comment
TiTaNiuM sAMuRai Posted September 4, 2002 Author Share Posted September 4, 2002 My intent is a polyline, but for any time I execute the PIO, making only 2 vertices, all I get is a 'Polyline' instead of the Plug-in Object. What gives? 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.