Ashishs Posted August 6, 2009 Share Posted August 6, 2009 I am looking for a code to count all layouts in current drawing. Tried Command "Layout" & selecting option "?", it lists all the layouts, but doesn't count. I am looking for result something like this- "Total numbers of Layouts are XX" Tnx 4 ur assistance in advance. Quote Link to comment Share on other sites More sharing options...
Freerefill Posted August 6, 2009 Share Posted August 6, 2009 (defun layouts( / ); (vl-load-com) (princ (strcat "\nThere are " (itoa (vla-get-count (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object))))) " layouts in this drawing.")) ) Short and sweet, just like it should be. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 6, 2009 Share Posted August 6, 2009 Come on mark... I'm sure you don't need to do all that ... (length (layoutlist)) 1 Quote Link to comment Share on other sites More sharing options...
Ashishs Posted August 6, 2009 Author Share Posted August 6, 2009 Tnx Lee & mark; really Short and sweet, just like it should be. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 6, 2009 Share Posted August 6, 2009 No problem, happy to help mate Quote Link to comment Share on other sites More sharing options...
eric_monceaux Posted March 27, 2013 Share Posted March 27, 2013 Sorry to redust this thread, but I am trying to utilize the layout count LISP that Lee and Mark created, but I have no idea how to initiate it. Can I get a little guidance? Quote Link to comment Share on other sites More sharing options...
mdbdesign Posted March 27, 2013 Share Posted March 27, 2013 Paste Lee code to command line and hit enter. Quote Link to comment Share on other sites More sharing options...
eric_monceaux Posted March 27, 2013 Share Posted March 27, 2013 Wow...I feel dumb... Is there a way to have that displayed in a field? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 28, 2013 Share Posted March 28, 2013 Is there a way to have that displayed in a field? Here is an example program to create an MText object containing a Field Expression referencing the number of paperspace layouts in a drawing; the program could of course be modified to insert the Field Expression in Text, MText or Attributes: [color=GREEN];; Layout Field - Lee Mac[/color] [color=GREEN];; Creates an MText object containing a Field Expression[/color] [color=GREEN];; referencing the number of paperspace layouts in a drawing.[/color] ([color=BLUE]defun[/color] c:layoutfield ( [color=BLUE]/[/color] ins ) ([color=BLUE]if[/color] ([color=BLUE]setq[/color] ins ([color=BLUE]getpoint[/color] [color=MAROON]"\nPick Point for Field: "[/color])) ([color=BLUE]vla-addmtext[/color] ([color=BLUE]vlax-get-property[/color] (LM:acdoc) ([color=BLUE]if[/color] ([color=BLUE]=[/color] 1 ([color=BLUE]getvar[/color] 'cvport)) 'paperspace 'modelspace)) ([color=BLUE]vlax-3D-point[/color] ([color=BLUE]trans[/color] ins 1 0)) 0.0 ([color=BLUE]strcat[/color] [color=MAROON]"%<\\AcExpr %<\\AcObjProp Object(%<\\_ObjId "[/color] (LM:ObjectID ([color=BLUE]vla-get-layouts[/color] (LM:acdoc))) [color=MAROON]">%).Count>% - 1 >%"[/color] ) ) ) ([color=BLUE]princ[/color]) ) [color=GREEN];; ObjectID - Lee Mac[/color] [color=GREEN];; Returns a string containing the ObjectID of a supplied VLA-Object[/color] [color=GREEN];; Compatible with 32-bit & 64-bit systems[/color] ([color=BLUE]defun[/color] LM:ObjectID ( obj ) ([color=BLUE]eval[/color] ([color=BLUE]list[/color] '[color=BLUE]defun[/color] 'LM:ObjectID '( obj ) ([color=BLUE]if[/color] ([color=BLUE]and[/color] ([color=BLUE]vl-string-search[/color] [color=MAROON]"64"[/color] ([color=BLUE]getenv[/color] [color=MAROON]"PROCESSOR_ARCHITECTURE"[/color])) ([color=BLUE]vlax-method-applicable-p[/color] ([color=BLUE]vla-get-utility[/color] (LM:acdoc)) 'getobjectidstring) ) ([color=BLUE]list[/color] '[color=BLUE]vla-getobjectidstring[/color] ([color=BLUE]vla-get-utility[/color] (LM:acdoc)) 'obj '[color=BLUE]:vlax-false[/color]) '([color=BLUE]itoa[/color] ([color=BLUE]vla-get-objectid[/color] obj)) ) ) ) (LM:ObjectID obj) ) [color=GREEN];; Active Document - Lee Mac[/color] [color=GREEN];; Returns the VLA Active Document Object[/color] ([color=BLUE]defun[/color] LM:acdoc [color=BLUE]nil[/color] ([color=BLUE]eval[/color] ([color=BLUE]list[/color] '[color=BLUE]defun[/color] 'LM:acdoc '[color=BLUE]nil[/color] ([color=BLUE]vla-get-activedocument[/color] ([color=BLUE]vlax-get-acad-object[/color])))) (LM:acdoc) ) ([color=BLUE]vl-load-com[/color]) ([color=BLUE]princ[/color]) Quote Link to comment Share on other sites More sharing options...
eric_monceaux Posted March 28, 2013 Share Posted March 28, 2013 Lee...once again...amazing! Thank you for all of your help! Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 28, 2013 Share Posted March 28, 2013 You're very welcome Eric! Quote Link to comment Share on other sites More sharing options...
BIGAL Posted March 28, 2013 Share Posted March 28, 2013 An alternative idea is why not read all layouts work out total number then number each sheet as 1 of 16 2 of 16 etc the method of sheet number can be based on a couple of rules. Number by layout list as created Number by layout list as appears on bottom of screen Number by the layout lable name eg D012 = 12 this allows non numbering of layouts Using a title block with attributes you have control of each atltribute change. Lastly its a work in progress does other stuff as well. Copies certain lines of a title block to corresponding newly created title blocks that are blank. Would it be of benefit to you ? When we are creating sometimes change order or add title blocks in middle. Create unique layouts that are not construction sheets but for imformation/discussion the latter not numbered. Ps thanks to Lee for previous info on layouts order. Quote Link to comment Share on other sites More sharing options...
Javamaster Posted April 13, 2022 Share Posted April 13, 2022 Could you give give me the lisp for counting layout in fields? so I do not have to update my page numbers? Thank you. Quote Link to comment Share on other sites More sharing options...
tombu Posted April 15, 2022 Share Posted April 15, 2022 On 4/13/2022 at 3:57 PM, Javamaster said: Could you give give me the lisp for counting layout in fields? so I do not have to update my page numbers? Thank you. It's on Lee Mac's website http://www.lee-mac.com/layoutfield.html Quote Link to comment Share on other sites More sharing options...
tombu Posted April 15, 2022 Share Posted April 15, 2022 For just counting layouts you could add this to Lee's code it's just his code for lfsheet with the extra stuff removed: ;|---------------------------------------------------------------------- Total Sheets Generates a field expression referencing the total number of paperspace layouts in the drawing. ----------------------------------------------------------------------|; (defun c:lfsheets ( ) ; Number of Layouts in drawing (layoutfield '(lambda ( obj ) (vla-put-textstring obj (strcat "%<\\AcExpr %<\\AcObjProp Object(%<\\_ObjId " (LM:objectid (vla-get-layouts (LM:acdoc))) ">%).Count>%-1 >%" ) ) ) ) ) and use this macro to set this number to a text selected in your drawing: ^C^C^P(or C:lfsheets (load "LayoutFieldV1-0 (1).lsp"));lfsheets Thanks Lee! Quote Link to comment Share on other sites More sharing options...
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.