MTRobin Posted August 20, 2019 Share Posted August 20, 2019 Hi Everyone, I have a script that converts a symbol to a group and then ungroups it. This is assigned to a shortcut so I can quickly "explode" symbols. I would like to add an IF statement so if the selected objects are a symbol is will convert symbol to group and then ungroup it. If it is a group it will just ungroup it. It would be great if this worked with a multiple selection of a mixture of groups and symbols. Can anyone help me write the IF statement? PROCEDURE ExplodeSymbol; VAR Selection : HANDLE; BEGIN Selection:= FSActLayer; SymbolToGroup(Selection,0); Ungroup; END; Run(ExplodeSymbol); Thank you, Maxwell Quote Link to comment
JBenghiat Posted August 20, 2019 Share Posted August 20, 2019 Not to rain on your scripting parade, but command+k command+u? Applying the script to all selected objects adds a couple levels of complexity — not a lot, but beyond basic. 1 Quote Link to comment
MTRobin Posted August 20, 2019 Author Share Posted August 20, 2019 I know about the key commands. I was trying to automate the process into a single script I can then assign a key command. Would you be able to help with applying the script to all objects? Thanks Maxwell Quote Link to comment
JBenghiat Posted August 20, 2019 Share Posted August 20, 2019 Untested PROCEDURE ExplodeSymbol; VAR Selection : HANDLE; arrSelH : dynarray[] OF handle; numObjects : integer; i :INTEGER; hPrev :HANDLE; {---------------------------------------------------------------------} FUNCTION AddToArr( h :HANDLE) : boolean; BEGIN numObjects := numObjects + 1; arrSelH[numObjects] := h; END; BEGIN ALLOCATE arrSelH[1..Count('sel=true')]; numObjects := 0; ForEachObjectInList( AddToArr, 2, 0, FSActLayer ); FOR i:=1 TO numObjects DO BEGIN if GetTypeN( arrSelH[i]) = 15 THEN BEGIN hPrev := PrevObj( arrSelH[i]); SymbolToGroup( arrSelH[i], 0); arrSelH[i] := NextObj(hPrev); END; if GetTypeN( arrSelH[i]) = 11 THEN begin HUngroup( arrSelH[i]); END; END; END; Run(ExplodeSymbol); Quote Link to comment
MTRobin Posted August 20, 2019 Author Share Posted August 20, 2019 Thank you! I am getting an error message. Please see attached. Best, Maxwell Quote Link to comment
Sam Jones Posted August 21, 2019 Share Posted August 21, 2019 Try this. It will only go on level deep. If you want to explode symbols in symbols or you want to ungroup groups within groups more is needed. PROCEDURE ExplodeSymbol; {---------------------------------------------------------------------} PROCEDURE Explode( h :HANDLE); BEGIN IF Gettype(h) = 15 THEN BEGIN SymbolToGroup(h,0); HUngroup(h); END ELSE IF Gettype(h) = 11 THEN HUngroup(h); END; {PROCEDURE Explode} {---------------------------------------------------------------------} BEGIN ForEachObject( Explode, ((SEL=TRUE))); END; Run(ExplodeSymbol); Quote Link to comment
JBenghiat Posted August 22, 2019 Share Posted August 22, 2019 On 8/20/2019 at 7:09 PM, MTRobin said: Thank you! I am getting an error message. Please see attached. Best, Maxwell Looking at Sam’s code, Count('sel=true') should probably be Count((SEL=TRUE)) I might also start with setting numObjects := Count((SEL==TRUE)) and testing: IF numObjects > 0 THEN BEGIN Allocate.... Quote Link to comment
MTRobin Posted August 22, 2019 Author Share Posted August 22, 2019 Thank you everyone! I got it to work. Best, Maxwell 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.