michaelk Posted March 3, 2020 Share Posted March 3, 2020 I'm trying to figure out if the script below doesn't work because of scripting errors or because this idea just won't work. The scenario is this: I have 10 sheet layers numbered A1..A10. I want to change the order or add one in the middle and renumber. I was hoping I could change the stacking order, then use a script to modify a subrange of those sheets using the new stacking order and a starting sheet stacking order number and a starting new sheet number. For simplicity I haven't put in a dialog box. I'm just assigning values in the script. Anyone have any ideas? PROCEDURE RenumberSheetLayers; VAR LayerInQuestion :HANDLE; S1,Ltyp,ReportStr : STRING; LyrTypInt, Counter, StackOrderBegin, StackOrderEnd, RenumStart, RenumCount, HowManyLayers, SheetsOnly : INTEGER; SheetPrefix, SheetSuffix : STRING; ShtLayer : DYNARRAY[] OF HANDLE; ShtLayerName : DYNARRAY[] OF STRING; BEGIN Counter := 1; LayerInQuestion:=FLayer; ALLOCATE ShtLayer[1..NumLayers+1]; ALLOCATE ShtLayerName[1..NumLayers+1]; StackOrderBegin := 2; StackOrderEnd := 5; SheetPrefix := 'A'; SheetSuffix := ''; RenumStart := 17; HowManyLayers := NumLayers; SheetsOnly := 1; For Counter := 1 to HowManyLayers DO BEGIN LyrTypInt := GetObjectVariableInt(LayerInQuestion,154); {***************************************************************************} {Layer type 1 is a design layer. Ignore and go to the next layer.} IF LyrTypInt = 1 THEN LayerInQuestion:=NextLayer(LayerInQuestion); { CASE I1 OF 1: LTyp := 'Design Layer'; 2: Ltyp := 'Sheet Layer'; END; } {***************************************************************************} {***************************************************************************} {Now we're in business. Layer type 2 is a Sheet Layer} IF LyrTypInt = 2 THEN Begin ShtLayer[SheetsOnly] := LayerInQuestion; ReportStr := Concat(ReportStr,GetName(ShtLayer[SheetsOnly])); SheetsOnly := SheetsOnly + 1; End; {If LyrTypInt is 2 (i.e. Sheet Layer} {***************************************************************************} END; {1 to number of layers} {***************************************************************************} {Reset the names to the date and time to prevent naming conflicts} For Counter := StackOrderBegin TO StackOrderEnd DO BEGIN SetName(ShtLayer[Counter],(Concat(Num2Str(0,Counter),'_',Date(2,2) ) )); END; RenumCount := RenumStart; FOR Counter := StackOrderBegin TO StackOrderEnd DO BEGIN SetName(ShtLayer[Counter],(Concat(SheetPrefix,Num2Str(0,Counter),SheetSuffix))); RenumCount := RenumCount +1; END; {Message(ReportStr);} END; {End of the whole shebang} Run(RenumberSheetLayers); Quote Link to comment
MullinRJ Posted March 4, 2020 Share Posted March 4, 2020 (edited) Hi Michael, I didn't read through all of your code, but I do see a mistake in your first FOR loop. You only index to the next layer inside an IF statement testing for Design Layers. If the layer is not TYPE 1 (a Design Layer) you don't index through the Sheet Layers. You need to move the NextLayer() call to the bottom of the FOR loop like this: For Counter := 1 to HowManyLayers DO BEGIN LyrTypInt := GetObjectVariableInt(LayerInQuestion, 154); {***************************************************************************} {Layer type 1 is a design layer. Ignore and go to the next layer.} IF (LyrTypInt = 1) THEN Begin { LayerInQuestion := NextLayer(LayerInQuestion); } {vvv Move to bottom of FOR loop vvv} { Do Design Layer stuff here, or remove this IF if there is nothing to do } End; {If LyrTypInt is 1 (i.e. Design Layer)} {***************************************************************************} {Now we're in business. Layer type 2 is a Sheet Layer} IF (LyrTypInt = 2) THEN Begin ShtLayer[SheetsOnly] := LayerInQuestion; ReportStr := Concat(ReportStr, GetName(ShtLayer[SheetsOnly])); SheetsOnly := SheetsOnly + 1; End; {If LyrTypInt is 2 (i.e. Sheet Layer)} LayerInQuestion := NextLayer(LayerInQuestion); {**** It works best here ****} END; {1 to number of layers} HTH, Raymond Edited March 4, 2020 by MullinRJ Quote Link to comment
michaelk Posted March 4, 2020 Author Share Posted March 4, 2020 Raymond Thanks! That makes sense. So I don't really even need to check if LyrTypInt =1, since I have nothing to do if it is :-). I'll give that a whirl. MK Quote Link to comment
michaelk Posted March 14, 2020 Author Share Posted March 14, 2020 There's still something wrong. Either I the stacking numbers don't work the way I think they do or I have another scripting issue. 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.