VectorGeek Posted January 20, 2010 Share Posted January 20, 2010 Hey scripters, I am looking for a way to ungroup PIOs (doors, windows) that are inserted into walls. I am using a ForEachObject call to check the drawing. In the subroutine, I check if the object is a wall, then use FIn3D to traverse the objects in the wall. But UnGroup(h) doesn't seem to work. I can delete the object so I know my procedure is working. Any ideas? V-G VectorWorks 2009 SP5 Windows XP Commodore PET. Quote Link to comment
Pat Stanford Posted January 20, 2010 Share Posted January 20, 2010 Since you can't have anything in a wall other than a symbol or a PIO, this does not surprise me a great deal. When I do it by hand I get a Door plus a bunch of lines/polylines that were the wall it was inserted in. What exactly are you trying to do and perhaps we can come up with a way to do it. Quote Link to comment
MullinRJ Posted January 20, 2010 Share Posted January 20, 2010 Have you tried SymbolToGroup(H, #)? Not sure if it will decompose a PIO, but it's worth a try. Raymond Quote Link to comment
MullinRJ Posted January 20, 2010 Share Posted January 20, 2010 SymbolToGroup() doesn't work inside a wall, but it does if you move the PIO into the open, where it becomes a sitting duck. Try this: ???if SetParent(PIOhand, ActLayer) then ??????SymbolToGroup(PIOhand, 0); Raymond Quote Link to comment
VectorGeek Posted January 21, 2010 Author Share Posted January 21, 2010 Thanks Ray - that works well. Code is below. The only problem is my routine is not processing the 2nd, 3rd etc. PIO in the wall, only the 1st. Anyone see what I am doing wrong? Pat - what I am doing is dumbing down a drawing prior to DWG export. We are having trouble with a particular client where the PIOs at their end come in with problems. Thanks for your help gents! {--------} Procedure test; VAR h, hInternal : HANDLE; boo : BOOLEAN; Procedure doit(h:HANDLE); BEGIN IF GetType(h) = 68 THEN BEGIN hInternal := FIn3D(h); WHILE hInternal <> NIL DO BEGIN IF GetType(hInternal) = 86 THEN BEGIN boo := SetParent(hInternal,ActLayer); SymbolToGroup(hInternal,0); END; hInternal := NextObj(hInternal); END; END; END; BEGIN ForEachObject(doit,((ALL))); END; Run(test); {--------} Quote Link to comment
ccroft Posted January 21, 2010 Share Posted January 21, 2010 Seems like that should work. You must be getting kicked out of the loop due to a nil handle. Could it be that once the PIO is moved out of the wall NextObj can't figure out what's next in the list? I think Ray knows what I'm about to suggest... Build a quickie array of all objects in wall = 86, and step thru that. (or maybe something else is happening that I can't see) Quote Link to comment
MullinRJ Posted January 21, 2010 Share Posted January 21, 2010 Charles, you da' man! Charles is 100% right (except for me suggesting an array :-p ). When you move the PIO out of its container (the wall) there is no next object after the PIO, so you have to get the next node before you cut your lifeline. An array of PIO handles will work, too, but I think this way is easier. Procedure test; VAR h, hInternal, SaveMe : HANDLE; boo : BOOLEAN; Procedure doit(h:HANDLE); BEGIN IF (GetType(h) = 68) THEN BEGIN { WALL } hInternal := FIn3D(h); WHILE (hInternal <> NIL) DO BEGIN SaveMe := NextObj(hInternal); { look ahead before you cut your link } IF (GetType(hInternal) = 86) THEN BEGIN { PIO } boo := SetParent(hInternal, ActLayer); SymbolToGroup(hInternal, 0); END; { if } hInternal := SaveMe; { continue or reconnect } END; { while } END; { if } END; { doit } BEGIN ForEachObject(doit, ALL); END; Run(test); Raymond Quote Link to comment
VectorGeek Posted January 21, 2010 Author Share Posted January 21, 2010 Brilliant! Thanks Ray and Charles for your solution. V-G Quote Link to comment
ccroft Posted January 22, 2010 Share Posted January 22, 2010 No Ray....YOU da' man. But you need to re-read my post. I never for a minute thought you would suggest an array. From our history I figured you'd know that would be my solution, since it seems to be my go to move when there's any kind of handle trouble. I like your 'look-ahead'. Haven't seen the Geek here for a while. Good to seeya! Quote Link to comment
MullinRJ Posted January 22, 2010 Share Posted January 22, 2010 Charles, ???Not reading things as written is a penchant of mine. OK, I got it - finally. In the same vein, I don't know how many times I've answered a question that was never asked, only to reread the original post before sending and scrap my entire draft. The follow up answer is, almost always, very short. ???On the topic of using arrays, a few months back I used a dynamic array of handles to apply random attributes to objects. I was amazed how much faster it was compared to the same code that stepped through the list of handles with a WHILE loop and NextSObj(). For 10-30K objects the array method was MUCH faster. Everything has its place. Raymond 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.