Jump to content
Developer Wiki and Function Reference Links ×

How to addsolids in Plug in objects? Vectorscript


Recommended Posts

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 by joshtreverton
Link to comment
  • Vectorworks, Inc Employee

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);

Link to comment

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);

Link to comment

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

Link to comment

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

Link to comment

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

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...