Jump to content
Developer Wiki and Function Reference Links ×

Extruding a polygon


Recommended Posts

I posted this a few days ago on a different thread but didn't get any response, so instead of highjacking that thread I thought it best to start a new one.  The issue is very simple, I created two 2D polygons and wanted to combine them (using the menu command, Compose) and then extrude it.

 

PROCEDURE Test;
VAR
    poly1, poly2, polyOut : HANDLE;
    TF : BOOLEAN;
BEGIN
    Poly( 0,0, 10,0, 10,10, 20,10 );
    poly1 := LNewObj;

    Poly( 0,0, -10,0, -10,10, -20,10 );
    poly2 := LNewObj; 
    
    SetSelect(poly1);
    SetSelect(poly2);
    
    DoMenuTextByName('Compose',0);

END;
Run(Test);

 

 

My apologies for dragging out this thread, but I can't figure out why I can't execute the example above in my larger script that I'm writing.  I've tested and checked that I do have the two polygons selected (the blue objects in the screen shot below) that I want to combine, and that they are the only two things selected before executing the DoMenuTextByName('Compose',0) command.  But for some reason, the two poly's don't combined.  If I convert the PIO into a group and grab the two poly's myself, I can execute the Compose command and they combine correctly which proves to me that the two poly's are touching each other and can be combined.  Hoping there might be someone smarter than I that can help me figure this out.  Happy to provide the code or VWX file if that's helpful.

Dave

 

 

    BeginPoly;

          ......

    EndPoly;
    h1:=LNewObj;

 

    BeginPoly;

          ......

    EndPoly;
    h2:=LNewObj;
    DSelectAll;
    SetSelect(h1);
    SetSelect(h2);
    DoMenuTextByName('Compose',0);

 

 

Screenshot 2024-04-05 at 4.54.56 PM.png

Link to comment

Since I haven't received a response, I've rewritten my script to collect the points (vertices) so I can create one single polygon to extrude.  The polygon is created, and I can move it, but I can't extrude it.  Any ideas why?  Is it possible my script is some how corrupted?

 

Dave

Screenshot 2024-04-10 at 10.37.58 AM.png

Link to comment

I think want to use AddPoint() or Add2DVertex() in your polygon. Also make sure to call SetPolyClosed() to ensure it is a closed object and can extrude. By your screen shot, it looks open.

 

Using DoMenuText calls in code that also uses handles can be problematic and is definitely not reliable in a PIO.

Link to comment

Thank you for your comments,  I'm switched the LineTo() command to AddPoint() command, and added a SetPolyClosed() command, but it still doesn't want to extrude.  Thoughts?

 

BeginPoly;
    FOR i:=1 TO k DO BEGIN
        {LineTo(FullArrayPts[i].x,FullArrayPts[i].y);}
        AddPoint(FullArrayPts[i].x,FullArrayPts[i].y);
    END;
EndPoly;
HMove(LNewObj,24",0);
SetPolyClosed(LNewObj,TRUE);
h1:=HExtrude(LNewObj,4",144");

Screenshot 2024-04-10 at 1.57.22 PM.png

Link to comment

I even created a smaller test script and it work correctly. 

But for some reason it doesn't work in my bigger script.

Dave

 

PROCEDURE Test;
VAR
    h1 : HANDLE;
    i : INTEGER;
    FullArrayPts: DYNARRAY[] OF POINT;
    
BEGIN

    ALLOCATE FullArrayPts [1..5];

    FullArrayPts[1].x:=0; FullArrayPts[1].y:=0;
    FullArrayPts[2].x:=5; FullArrayPts[2].y:=1;
    FullArrayPts[3].x:=9; FullArrayPts[3].y:=4;
    FullArrayPts[4].x:=12; FullArrayPts[4].y:=8;
    FullArrayPts[5].x:=13; FullArrayPts[5].y:=13;

BeginPoly;
    FOR i:=1 TO 5 DO BEGIN
        AddPoint(FullArrayPts[i].x,FullArrayPts[i].y);
    END;
EndPoly;

{SetPolyClosed(LNewObj,TRUE);}
h1:=HExtrude(LNewObj,4",144");

END;
Run(Test);

Link to comment
12 minutes ago, JBenghiat said:

If this is part of a PIO, use BeginXtrd/EndXtrd instead of HExtrude.

Originally, I used BeginXtrd/EndExtrd, and calculated the vertices but abandoned that idea early on.  Thinking about it now, I might be able to revisit that idea and use it with the FOR/TO command.

I'll let you know how it goes.

 

Dave

Link to comment

Sorry for all the replies.  The reason why I abandoned the BeginXtrd/EndXtrud idea is because I need to do an OffsetPoly() command before the poly is extruded, and I don't think that's allowed within a BeginXtrd/EndXtrud command, and am unsure how I would do that after the BeginXtrd/EndXtrud command.  Is it just a matter of using the GetCustomObjectPath() and then after getting a handle to the path, execute the OffsetPoly() command?

 

Dave

Link to comment

I tried the BeginXtrd/EndXtrud idea, with GetCustomObjectPath() and OffsetPoly(), but nothing.  The extruded poly was completely missing from the 2D and 3D views.  There was no trace of it anywhere.  I couldn't even get the BeginXtrd/EndXtrud to work by it's self which is weird, which makes me wonder if the script is corrupted or something.

Dave

 

BeginXtrd(144",240");
    FOR i:=1 TO k DO BEGIN
        {LineTo(FullArrayPts[i].x,FullArrayPts[i].y);}
        AddPoint(FullArrayPts[i].x,FullArrayPts[i].y);
    END;
EndXtrd;

{h1:=GetCustomObjectPath(LNewObj);
h2:=OffsetPoly(h1,6", 1, TRUE,  TRUE, 1, 0.1);}

Screenshot 2024-04-10 at 2.42.34 PM.png

Link to comment

You still need to define the object being extruded, so don't omit the BeginPoly/EndPoly calls

 

GetCustomObjectPath works on Plug-in objects -- that won't get the extrude base, as an extrude is a native object type. Use OffsetPoly after EndPoly and before EndXtrd.

Link to comment

WINNER, WINNER, CHICKEN DINNER!!!

 

Your right, I needed to define the object being extruded.  It works now.  Still not sure why the option using the BeginPoly/EndPoly with the HExtrude() afterwards didn't work, but I'm so happy to have found a solution, I don't really care.  Big thank you for helping me think through this.

 

Dave

 

BeginXtrd(0',12');
    BeginPoly;
        FOR i:=1 TO k DO BEGIN
            AddPoint(FullArrayPts[i].x,FullArrayPts[i].y);
        END;
    EndPoly;
    h1:=OffsetPoly(LNewObj,6", 1, TRUE,  TRUE, 1, 0.1);
EndXtrd;

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