joshtreverton Posted January 10, 2013 Share Posted January 10, 2013 (edited) Can someone help I am trying to add two solids created in vectorscript, I have been testing how to do this : The script works when I run it as a vectorscript in the resource browser, however when I use the script in a PIO the two solids don't combine... This is the script I've been using: Procedure AddSolidTest; VAR result:INTEGER; tempHandle, tempHandle1, tempHandle2, objectHandle:HANDLE; BEGIN BeginXtrd(0,80); ClosePoly; Poly(-80,-17.5,0,62.5,0,-62.5); objectHandle := LNewObj; EndXtrd; ResetOrientation3D; BeginXtrd(0,80); Poly(-30,200,50,500,3,-62.5); objectHandle := LNewObj; EndXtrd; ResetOrientation3D; tempHandle1 := LObject; tempHandle := PrevObj(tempHandle1); result := AddSolid(tempHandle, tempHandle1, tempHandle2); ResetOrientation3D; END; Run(AddSolidTest); It is just a test for something that is alot bigger, as I say I just can't get it to work when using the script as a Plug-in (I have the same problems when I try and subtract solids also). Has anyone else managed to get add solids to work in a PIO Ta Josh Edited January 11, 2013 by joshtreverton Quote Link to comment
Vectorworks, Inc Employee klinzey Posted January 10, 2013 Vectorworks, Inc Employee Share Posted January 10, 2013 Don't rely on LObject or PrevObj unless absolutely necessary. Try this: VAR result:INTEGER; tempHandle, tempHandle1, tempHandle2:HANDLE; BEGIN BeginXtrd(0,80); ClosePoly; Poly(-80,-17.5,0,62.5,0,-62.5); EndXtrd; tempHandle1 := LNewObj; BeginXtrd(0,80); Poly(-30,200,50,500,3,-62.5); EndXtrd; tempHandle2 := LNewObj; result := AddSolid(tempHandle1, tempHandle2, tempHandle); END; Run(AddSolidTest); Quote Link to comment
joshtreverton Posted January 11, 2013 Author Share Posted January 11, 2013 Excellent That worked exactly as I wanted, the confusion lay with it working as a script in a Script Pallette but not in a PIO Cheers klinzey Quote Link to comment
Vectorworks, Inc Employee klinzey Posted January 11, 2013 Vectorworks, Inc Employee Share Posted January 11, 2013 If you check you will probably find that LObject or PrevObj(tempHandle1) is the handle to the Plug-in. Quote Link to comment
joshtreverton Posted January 14, 2013 Author Share Posted January 14, 2013 Kevin, I am now trying to get a solid extrude and an 'extrude along path' which were created in septerate procedures to combine. I can't seem to get them to work I think that the problem is how to get the AddSolids function to recognise the handle of the path object... Any help? e.g. Procedure AddSolidTest; VAR result:INTEGER; tempHandle, tempHandle1, tempHandle2:HANDLE; objectHandle:HANDLE; ArcNurbed:HANDLE; CurvedWall3D:HANDLE; Procedure DrawPolgonA; BEGIN FillPat(1); FillBack(65535,65535,65535); BEGIN Arc(-2000,2000,2000,-2000,45,90); objectHandle := LNewObj; ArcNurbed:= ConvertToNURBS (LNewObj, FALSE); END; BeginGroup; ClosePoly; Poly(-62.5,2000,62.5,2000,62.5,0,-62.5,0); objectHandle := LNewObj; EndGroup; tempHandle2 := LNewObj; objectHandle := CreateCustomObjectPath('Extrude Along Path', ArcNurbed, tempHandle2); CurvedWall3D := LNewObj; hMove(CurvedWall3D, 0, -1800); DSelectAll; END; Procedure DrawPolgonB; BEGIN BeginXtrd(-1000,1000); Poly(-30,200,50,500,3,-62.5); EndXtrd; tempHandle2 := LNewObj; DSelectAll; END; Procedure DrawAddSolid; BEGIN result := AddSolid(CurvedWall3D, tempHandle2, tempHandle); message(result); END; BEGIN DrawPolgonA; DrawPolgonB; DrawAddSolid; END; Run(AddSolidTest); Quote Link to comment
CipesDesign Posted January 14, 2013 Share Posted January 14, 2013 Sorry to jump in. I know very little about scripting, but using the Add Solids command I was able to easily combine an Extrude and and EAP... Quote Link to comment
joshtreverton Posted January 14, 2013 Author Share Posted January 14, 2013 In the VectorWorks environment, as you say, it is easy to combine the two, it is within the script that I can't seem to get it to work... Saddly it must be done 'in-script'. Thanks for your comment though. Quote Link to comment
MullinRJ Posted January 15, 2013 Share Posted January 15, 2013 Josh, After playing with this for an hour or so, I think your problem lies in the fact that the curved wall is an ExtrudeAlongPath (EAP) object, which is a Plugin Object. Though I am not versed in all the ins and outs of such beasts, you can add them with VS AddSolid() if it's run from a separate script. This leads me to believe that the EAP in your script does not exist until after your script finishes execution, and that has to do with the EAP's internal script running AFTER yours is done. Once both scripts finish, then you can add the objects with the AddSolid() command, but it has to be initiated in another script, which I'm sure defeats your whole purpose. Maybe a Sweep is better suited for this than an EAP. After your script creates your 3D objects, select them both manually and run this script: Procedure AddSolidTest; { Add the 1st two selected objects with AddSolid(). } VAR result :INTEGER; CurvedWall3D, PolyBHnd, SolidHnd :HANDLE; BEGIN CurvedWall3D := FSActLayer; PolyBHnd := nextSObj(CurvedWall3D); result := AddSolid(CurvedWall3D, PolyBHnd, SolidHnd); message('result = ', result); END; Run(AddSolidTest); This shows that AddSolid() will work on an EAP and an Extrude, but only after the EAP has finished generating. HTH, Raymond Quote Link to comment
joshtreverton Posted January 15, 2013 Author Share Posted January 15, 2013 Thanks Raymond, The second script worked, however, Saddly you're right I really need it all to execute within one script. Is there a way to force the EAP object to execute first or wheather there is a function to 'Convert to Generic Object' such that the two objects can then combine? Or if I was using a Sweep is there a way of setting out a point outside the polygon which to sweep around? Cheers, Joshua Quote Link to comment
MullinRJ Posted January 15, 2013 Share Posted January 15, 2013 Hi Joshua, ???I'm pretty sure you can't force the EAP to generate before your script ends, and I looked for a way to force it to a Generic Solid but found none. I still think the EAP would have to generate before it could be converted to a Solid. Maybe someone at the Mother Ship could confirm if this is all true. ???Use a Locus to set the center of rotation. Here's an example that draws your wall and moves it into position. { View must be TOP, or Top/Plan } BeginSweep(45, 90, 5, 0); { sweep center is (0, 0, 0) } Locus(0, 0); Rect(-62.5, 1000, 62.5, -1000); { profile center is (0, 0) } hMove(LNewObj, 2000, 0); { move profile right } EndSweep; SetRot3D(LNewObj, 90, 0, 90, 0, 0, 0); { stand sweep up and rotate 90 (z) } hMove(LNewObj, 0, -1800); { move sweep into plan position } Raymond Quote Link to comment
joshtreverton Posted January 15, 2013 Author Share Posted January 15, 2013 Raymond, That's great cheers, I have never really got the hang of Locus (although they have always looked useful from afar...) I think that I will just have to re-write my script to use sweeps instead, which should overal reduce the length of my script anyway... Thannks. Joshua 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.