DCarpenter Posted April 10 Share Posted April 10 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); Quote Link to comment
DCarpenter Posted April 10 Author Share Posted April 10 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 Quote Link to comment
JBenghiat Posted April 10 Share Posted April 10 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. Quote Link to comment
DCarpenter Posted April 10 Author Share Posted April 10 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"); Quote Link to comment
JBenghiat Posted April 10 Share Posted April 10 If this is part of a PIO, use BeginXtrd/EndXtrd instead of HExtrude. Quote Link to comment
DCarpenter Posted April 10 Author Share Posted April 10 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); Quote Link to comment
DCarpenter Posted April 10 Author Share Posted April 10 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 Quote Link to comment
DCarpenter Posted April 10 Author Share Posted April 10 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 Quote Link to comment
DCarpenter Posted April 10 Author Share Posted April 10 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);} Quote Link to comment
JBenghiat Posted April 10 Share Posted April 10 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. Quote Link to comment
DCarpenter Posted April 10 Author Share Posted April 10 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; 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.