WhoCanDo Posted May 26 Share Posted May 26 Hi, I work in 2D on the Design layers. When I'm given more designs to draw than will fit on an A3 page at a reasonable scale, I will draw them anywhere on the Design layer and then place a rectangle around each design to create a bounding box for each viewport. Then I can sort those viewport crops into an order of my choice and create multiple Sheet layers to accommodate the compete project. The latest project has 34 viewports on 3 Sheet layers when finished. 34 viewports created one at a time is a pain so I have written a macro create all the viewports so I can cut and paste them onto the Sheet layers as I see fit. The problem is that the macro below randomly selects my bounding boxes and makes viewports of the contents, but the bounding boxes it ignores, it just makes a viewport of the whole layer. From the 34 viewports on my current project, it makes 15 viewports from the bounding boxes, and 19 layer viewports. It always uses the same bounding boxes for the 15, and always creates the the same layer viewports. Any ideas as to how to correct this ? procedure Main; var Lyr, LineStyleName : string; i, j : integer; Pt : Array [1..500, 1..500] of real; hL, hV : handle; procedure Log_Selected (h : handle); begin SetName (h, 'Tmp'); i := i + 1; Pt[i, 1] := LeftBoundN (N='Tmp'); Pt[i, 2] := BotBoundN (N='Tmp'); DelName ('Tmp'); end; procedure Create_Viewport; begin hV := PickObject (Pt[j, 1], Pt[j, 2]); if (hV <> Nil) then begin SetSelect (hV); DoMenuTextByName ('Create Viewport', 0); Layer (Lyr); end; end; begin hL := ActLayer; Lyr := GetLName (hL); i := 0; ForEachObject (Log_Selected, ((Sel=True) & (L=Lyr))); DSelectAll; For j := 1 to i do begin Create_Viewport; end; end; run (Main); Quote Link to comment
MullinRJ Posted May 26 Share Posted May 26 Hello @WhoCanDo, I did not try to replicate your problem, but I suspect it may have something to do with using PickObject to make your selections. Instead, I built an array of HANDLES to store the crop objects and used the handle array of the crop objects to define the VPs. Here's the sample code: procedure Main; var Lyr : string; i, j : integer; Hands :Array [1..500] of Handle; procedure Log_Selected (h : Handle); begin i := i + 1; Hands[i] := h; end; procedure Create_Viewport(hv :Handle); begin if (hv <> Nil) then begin SetSelect (hv); DoMenuTextByName ('Create Viewport', 0); Layer (Lyr); end; end; BEGIN Lyr := GetLName (ActLayer); i := 0; ForEachObject( Log_Selected, Sel & (L=Lyr) ); DSelectAll; For j := 1 to i do Create_Viewport(Hands[j]); END; Run(Main); It works on a really simple drawing with 5 mock view ports. I get 5 VPs when done. HTH, Raymond 3 Quote Link to comment
WhoCanDo Posted May 26 Author Share Posted May 26 Perfect Raymond, your a time saver LOL 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.