Jump to content

Ungrouping PIOs in Walls


VectorGeek

Recommended Posts

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.

Link to comment

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

{--------}

Link to comment

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)

Link to comment

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

Link to comment

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!

Link to comment

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

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