- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 / *  
 M o d i f i e d   b y   H a n s e l   M o n i z  
 t h a n k s   t o    
 P i e r r e   F e l i x   B r e t o n   2 0 1 1   f o r   t h e   o r i g i n a l   c o d e  
  
 W h y :    
 	 	 R e v i t   F B X f i l e s   d o n ' t   i m p o r t   o n   l a y e r s   a n d   w e   w a n t   t o   u s e   t h e m .  
  
 W h a t :  
 	 	 S e t   e a c h   o b j e c t   f r o m   a   r e v i t   F B X   m o d e l   o n t o   a   l a y e r   b a s e d   o n   t h e   n a m e   o f   t h e   C a t e g o r y   a n d   F a m i l y  
 * /  
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
  
 ( - - s c r i p t   b e g i n  
 	  
 	 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 	 - -     F U N C T I O N S  
 	 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 	  
 	 - -   p a s s   a   n o d e   a n d   a   l a y e r   n a m e  
 	 - - i f   l a y e r   d o n ' t   e x i s t s ,   i t   i s   c r e a t e d ,   o t h e r w i s e ,   t h e   n o d e   i s   a d d e d   t o   i t  
 	 f u n c t i o n   s e t O b j e c t T o L a y e r   s t r L a y e r N a m e   o b j   =    
 	 (  
 	 	 l o c a l   t h e L a y e r   =   u n d e f i n e d  
  
 	 	 - - i f   u n d e f i n e d ,   c r e a t e   t h e   l a y e r  
 	 	 t h e L a y e r   =   L a y e r M a n a g e r . n e w L a y e r F r o m N a m e   s t r L a y e r N a m e  
 	 	 	 	  
 	 	 - - a t t e m p t   t o   u s e   t h e   e x i s t i n g   l a y e r  
 	 	 t h e L a y e r   =   L a y e r M a n a g e r . g e t L a y e r F r o m N a m e   s t r L a y e r N a m e  
 	 	  
  
 	 	 - - m o v e   t h e   n o d   t o   t h e   d e s i r e d   l a y e r  
 	 	 i f   t h e L a y e r   ! =   u n d e f i n e d   d o   t h e L a y e r . A d d N o d e   o b j  
 	 ) - -  
 	 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 	 - -     M A I N  
 	 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 	  
 	 - - t o   p r e v e n t   d e l a y s   a n d   u i   r e f r e s h e s  
 	 m a x   c r e a t e   m o d e  
 	 l o c a l   b o o l R e s t o r e L a y e r M a n a g e r   =   f a l s e  
 	 i f   L a y e r M a n a g e r . i s D i a l o g O p e n ( )   d o    
 	 (  
 	 	 L a y e r M a n a g e r . c l o s e D i a l o g ( )  
 	 	 b o o l R e s t o r e L a y e r M a n a g e r   =   t r u e  
 	 )  
  
 	  
 	  
 	 - - c l e a r s   m a x s c r i p t   l i s t e n e r  
 	 c l e a r l i s t e n e r ( )  
 	 - - s t a m p i n g   i n f o r m a t i o n   i n   t h e   l i s t e n e r  
 	 f o r m a t   " % \ n "   " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "  
 	 f o r m a t   " % \ n \ n "   " L o o p i n g   t h r o u g h   s c e n e   e n t i t i e s . . . . . . "  
  
 	 - - l o o p   t h r o u g h   a l l   s c e n e   o b j e c t s   t o   b u i l d   a   s t r i n g   u s e f u l   f o r   l a y e r   n a m i n g  
 	 - - 	 e x :     R e v i t   C a t e g o r y   +   R e v i t   F a m i l y   = =   O n e   L a y e r  
 	 - - 	 e x :     R e v i t   F a m i l i y   +   R e v i t   T y p e   = =   O n e   L a y e r  
 	  
 	 f o r   o b j   i n   O b j e c t s   d o  
 	 (  
 	  
 	 	 - - e x t r a c t   R e v i t   B a s i c   P r o p e r t i e s   f r o m   C u s t o m   A t t r i b u t e s  
 	 	 - - 	 t h i s   o n l y   w o r k s   w i t h   d a t a   i m p o r t e d   f r o m   F B X  
 	 	 - - 	 t h i s   o n l y   w o r k s   i f   C o m b i n e   B y   o p t i o n s   f r o m   F i l e   L i n k   h a s   n o t   d e s t r o y e d   s o m e   o f   t h o s e   p r o p e r t i e s  
  
 	 	 - - i n i t i a l i z e     t h e   a n   a r r a y   c o n t a i n i n g   e x t r a c t d   p r o p e r t e i s  
 	 	 - -   t h o s e   p r o p e r t i e s   w i l l   b e   u s e d   t o   b u i l d   a   l a y e r   n a m e  
 	 	 l o c a l   a r S t r O b j P r o p e r t y V a l u e s   =   # ( )  
 	 	  
 	 	 - - e x t r a c t   c u s t o m   a t t r i b u t e s   f r o m   n o d e  
 	 	 l o c a l   o b j C u s t A t t r i b s   =   c u s t A t t r i b u t e s . g e t   o b j   1   b a s e o b j e c t : f a l s e  
 	 	  
 	 	 - - c h e c k   i f   t h e   o b j e c t   h a s   c u s t o m   a t t r i b u t e s  
 	 	 i f   ( o b j C u s t A t t r i b s   ! =   u n d e f i n e d )   d o    
 	 	 (  
 	 	 	 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 	 	 	 - -   B E G I N   H A C K   H A C K   H A C K  
 	 	 	 - -   T h e   f o l l o w i n g   i s   a   b a n d   a i d   f i x   t o   w o r k a r o u n d   t h e   f a c t   t h a t   t h e   F B X   R e a d e r   o f   m a x  
 	 	 	 - -   L e a v e s   P a r t s   w i t h   e m p t y   m e t a   d a t a .     A s   a   r e s u l t ,   t h e y   w o u l d   a l l   e n d   u p   i n t o   t h e   s a m e  
 	 	 	 - -   L a y e r .     T h e   f o l l o w i n g   c o p i e s   t h e   O r i g i n a l   P a r t   P r o p e r t i e s   i n t o   t h e   C a t e g o r y   P r o p e r t i e s  
 	 	 	 - -   i n   o r d e r   t o   l a n d   o n   t h e   a p p r o p r i a t e   l a y e r s .  
 	 	 	 	 	 - - E N D   H A C K   H A C K   H A C K  
 	 	 	 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 	 	 	  
 	 	 	  
 	 	 	 / *  
 	 	 	 T y p i c a l   R e v i t   P r o p e r t i e s :  
 	 	 	  
 	 	 	 	 . C a t e g o r y _ N a m e   :   s t r i n g  
 	 	 	 	 	 	  
 	 	 	 * /  
 	 	 	  
 	 	 	 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 	 	 	 - - e x t r a c t   a   f e w   b a s i c   p r o p e r t i e s   f r o m   t h e   o b j e c t   t o   u s e   a   a   w a y   t o   b u i l d   t h e   a p p r o p r i a t e   l a y e r   n a m e  
 	 	 	 l o c a l   a r P r o p e r t i e s T o E x t r a c t   =   # ( # C a t e g o r y _ N a m e )   - - -   C H A N G E   M E   T O   A N Y   O T H E R   P R O P E R T Y   N A M E  
 	 	 	  
 	 	 	 - - l o o p   t h r o u g h   p r o p e r t i e s   t o   b e   e x t r a c t e d   f r o m   n o d e s  
 	 	 	 f o r   t h e P r o p e r t y   i n   a r P r o p e r t i e s T o E x t r a c t   d o  
 	 	 	 (  
 	 	 	 	 i f   ( h a s P r o p e r t y   o b j C u s t A t t r i b s   t h e P r o p e r t y )   d o  
 	 	 	 	 (  
 	 	 	 	 	 - - c o n c a t e n a t e   t h e   s t r i n g   w i t h   t h e   v a l u e   c o n t a i n e d   i n   t h e   p r o p e r t y  
 	 	 	 	 	 a p p e n d   a r S t r O b j P r o p e r t y V a l u e s   ( g e t P r o p e r t y   o b j   t h e P r o p e r t y )  
 	 	 	 	 ) - - e n d   i f  
 	 	 	 ) - - e n d   l o o p   t h r o u g h   p r o p e r t i e s  
 	 	 	 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 	 	 	  
 	 	 	 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 	 	 	 - -   c o n c a t e n a t e   l a y e r   n a m e   f r o m   c o l l e c t e d   p r o p e r t i e s   a n d   m o v e   n o d e   t o   t h e   d e s i r e d   l a y e r  
 	 	 	 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 	 	 	 l o c a l   s t r O b j T a r g e t L a y e r N a m e   =   " "  
 	 	 	 l o c a l   i n d e x C o u n t   =   1  
 	 	 	 f o r   i   i n   a r S t r O b j P r o p e r t y V a l u e s   d o    
 	 	 	 (  
  
 	 	 	 	 s t r O b j T a r g e t L a y e r N a m e   = s t r O b j T a r g e t L a y e r N a m e   +   i  
 	 	 	 	 i f   i n d e x C o u n t   ! =   a r S t r O b j P r o p e r t y V a l u e s . c o u n t   d o   s t r O b j T a r g e t L a y e r N a m e   =   s t r O b j T a r g e t L a y e r N a m e   +   "   |   "  
 	 	 	 	 i n d e x C o u n t   =   i n d e x C o u n t   +   1  
 	 	 	 	  
 	 	 	 )  
 	 	 	  
 	 	 	  
 	 	 	 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 	 	 	 - -   m o v e   n o d e   t o   t h e   d e s i r e d   l a y e r  
 	 	 	 - - c r e a t e   a   l a y e r   n a m e   a n d   m o v e   t h e   n o d e   o n   i t ,   o n l y   i f   p r o p e r t i e s   w h e r e   e x t r a c t e d   f r o m   t h e   n o d e  
 	 	 	 i f   ( s t r O b j T a r g e t L a y e r N a m e   ! =   " " )   d o  
 	 	 	 (  
 	 	 	 	  
 	 	 	 	 f o r m a t   " % \ n "   s t r O b j T a r g e t L a y e r N a m e  
 	 	 	 	 s e t O b j e c t T o L a y e r   s t r O b j T a r g e t L a y e r N a m e   o b j    
 	 	 	 ) - - e n d   i f  
 	 	 	 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 	  
 	 	 	  
 	 	 ) - - e n d   i f   ( ( o b j C u s t A t t r i b s   ! =   u n d e f i n e d )    
 	 	  
  
 	 ) - - e n d   f o r   l o o p ,   m o v e   t o   n e x t   o b j e c t  
 	  
 	  
 	 i f   b o o l R e s t o r e L a y e r M a n a g e r   = =   t r u e   d o    
 	 (  
 	 	 l a y e r m a n a g e r . e d i t l a y e r b y n a m e   " "  
 	 )  
 	  
 ) - - s c r i p t   e n d s  
  
  
  
 