Jump to content

Tracking the Stacking Order in Symbol Components


Recommended Posts

  • Vectorworks, Inc Employee

I have a need to replace multiple polylines within the front and left symbol components, with polygons in hundreds of symbols. I can do this quite easily using ConvertToPolygon(), however I need the stacking order to be maintained so that the polygon is in the same stacking position as the polyline it replaces. The symbols have polylines at the root level of the component groups, but there are also groups that contain polylines so things get complicated.

 

I am looking for some ideas on how I might be able to do my poly replacement while maintaining the stacking order. Wondering if there is any way to replace one handle with another to achieve this? I suspect the answer is going to be to build an array within each container (component group or group), look at the array number of the polyline, replace it, then use HMoveBackward() to put the new poly back to where the original one was.

 

Any better ideas?

 

Thanks!

Link to comment

I THINK, you could get the handle to the object at the bottom of the stacking order so you know when you are done. Then start at the top of the stacking order, Convert to Polygon, Send to Back.  Just check each object as it comes to the front and stop after you process the original bottom object.

 

But since they view components are groups and there is no LinGroup function, I think you will need to do something like:

 

H1:=FInGroup;
H2:=H1;
While H2<> Nil do
	Begin
		H2:=NextObj(H2);  {this will either get you the top of the stacking order or one past, so this may need more}
	End;

While H2 <> H1 do
	Begin
		H3:=PreviousObj(H2);
		ConvertToPolygon(H2,300);
		HMoveBackward(LNewObj, True);  {should move the converted polygon to the back of the stack}
		H2:=H3;	
	End;

 

I probably have more handles in there than necessary, I may also be skipping the object at the bottom of the list. Maybe it would be better to convert the first object and use the handle to that to decide when to stop.

 

HTH

 

 

Link to comment
  • Vectorworks, Inc Employee

Thanks Pat. Your idea worked for 95% of cases which is good enough. Here is the final proc I came up with:
 

Procedure ConvertIt(h1 : HANDLE); { convert all polylines to polygons }
VAR
    h2, h3, h4 : HANDLE;
    b1 : BOOLEAN;
BEGIN { ConvertIt }
    IF GetType(h1) = 21 THEN BEGIN
        h3 := GetParent(h1); { h3 is handle to polyline container }
        h2 := ConvertToPolygon(h1, 8); { new polygon is created on active layer! }
        SetObjectVariableBoolean(h2, 1160, True); { make polygon screen plane }
        b1 := SetParent(h2, h3); { move new polygon to polyline container }
        HMoveBackward(h2, True); { move new polygon to back of container }
        h4 := FInGroup(h3); { get handle to first item in container group }
        REPEAT
            IF NextObj(h4) <> h1 THEN BEGIN
                HMoveForward(h2, False); { move new polygon forward to same stack position as polyline }
                h4 := NextObj(h4);
            END ELSE h4 := Nil;
        UNTIL (h4 = h1) | (h4 = Nil);
        DelObject(h1); { delete original polyline }
    END;
END; { ConvertIt }

 

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