Jump to content
Sign in to follow this  
Pat Stanford

Convert Nested Symbols to Groups

Recommended Posts

Someone on the Vectorworks mail list needed a way to convert nested symbols to groups. The attached script converts all nested symbols in placed symbols in a drawing to groups. It does not purge the drawing, but that functionality could be easily added.

Copy everything in the code block and paste it into a new blank vectorscript.

Let me know if you have problems.

Procedure UnNest_Symbols;

{Converts nested symbols to Groups}
{Converts sub-symbols in all placed symbols in a drawing to groups}
{It will convert the 2D portion of the symbol if used in Top/Plan the 3D portion otherwise.}
{All sub-symbols will also be converted.}

{August 12, 2011  Version 1}
{? 2011, Coviana, Inc - Pat Stanford pat@coviana.com}
{Licensed under the GNU Lesser General Public License}
{No rights reserves}
{Use at your own risk. May cause pimples or hysterical blindness}

Var
PlacedSymbol:	Handle;


Procedure Doit(ProcessObject :Handle);


Var
	MyDefinition:	Handle;
	NestedObject:	Handle;
	SymDefName:		String;

Begin
	SymDefName:=GetSymName(ProcessObject);  {get the name of the symbol definition}
	MyDefinition:=GetObject(SymDefName);	{use the name to get a handle to the definition}

	If GetType(MyDefinition)=16 then		{only work on symbol definitions}
		Begin
			NestedObject:=FInSymDef(MyDefinition);	{Get the first object in the symbol def}
			While NestedObject <> Nil do 	{make sure you process all the objects in symbol def}
				Begin
					If GetType(NestedObject)=15 then SymbolToGroup(NestedObject,1); 	{if a symbol convert to a group}
					NestedObject := NextObj(NestedObject);	{get a handle to the next object in the symbol}
				End;
		End;				
End;

Begin
ForEachObject(DoIt,((T=SYMBOL)));
End;

Run(UnNest_Symbols);

Share this post


Link to post

Hysterical blindness... oh I'm so there!

But seriously nice script Pat, even just from a layout/efficient code perspective.

*General thanks*

J

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×