+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 14
  1. #1
    Forum Newbie
    Using
    AutoCAD 2008
    Join Date
    Feb 2010
    Posts
    8

    Default Need Help for counting the layouts and updating the same in title block

    Registered forum members do not see this ad.

    Hi.,

    I need a lisp routine to count the number of layouts (layouts name will be not be specific & is random ) in a drawing from starting to end, and update the sheet no field in the title block ex: '1 of 5', '2 of 5', etc...

    Can any one guide how to do it??


    regards

    r.sekar

  2. #2
    Forum Deity Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draftsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electrical.
    Using
    AutoCAD 2014
    Join Date
    Oct 2009
    Location
    Great Syria , Lives in Abu Dhabi
    Posts
    3,868

    Default

    This would give you the number of layouts that you have in a drawing .

    Code:
    (length  (layoutlist))
    But what do you mean by update the sheet no field in the title block ?

  3. #3
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    16,784

    Default

    In Pseudo Code it might be something along the lines of:

    • Initialise counter variable to 1 and another variable to store number of layouts (as a string)
    Code:
    (setq sheet 1)
    (setq total (itoa (length (layoutlist))))
    • Iterate through list of layouts.
    Code:
    (foreach layout (layoutlist)
     ...
    )
    • For each layout name, acquire a SelectionSet of attributed blocks of a specific name inserted in that layout
    Code:
    (ssget "_X" (list (cons 0 "INSERT") (cons 66 1) (cons 2 "YourBlockName") (cons 410 layout)))
    • Iterate through the attributes of each block in the SelectionSet (entnext)
    • Update the attribute with tag pertaining to the sheet number using a concatenation of the counter variable and variable containing total number of layouts
    Code:
    (strcat (itoa sheet) " of " total)
    • Increment the counter
    Code:
    (setq sheet (1+ sheet))
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  4. #4
    Super Member
    Computer Details
    woodman78's Computer Details
    Operating System:
    Win XP
    Computer:
    Dell GX280
    Discipline
    Transport
    woodman78's Discipline Details
    Occupation
    Road Design Engineer
    Discipline
    Transport
    Details
    I work in a local authority design office with a staff of 13. We carry out road schemes ranging from overlays up to 2 km long new schemes.
    Using
    Civil 3D 2011
    Join Date
    Jul 2009
    Location
    Ireland
    Posts
    684

    Default

    r.sekar,

    There is a much easier way to do it with fields. The only thing is that you would need to number the layouts as 1,2,3,4,5.....etc. And use another field for the total number pages. I have it setup this way and it works very well. A simple regenall updates the fields.
    I attach a layout with the fields.

    Note also a field used for the scale. If you change the viewport scale and regenall the scale updates. The sheet size is updated based on the Page Setup used to plot.
    new block.dwg

  5. #5
    Super Member irneb's Avatar
    Computer Details
    irneb's Computer Details
    Operating System:
    Win7 Pro 64bit
    Computer:
    Antec One Hundred
    Motherboard:
    ASUS P8P67-Pro P67
    CPU:
    Intel i7 2600 @ 3.4GHz
    RAM:
    16GB-1600MHz
    Graphics:
    GeForce GT 430 (1GB)
    Primary Storage:
    Seagate1TB SATA2 - 7200rpm
    Monitor:
    Samsung 2333TN 23" 1920 x 1080 Full HD LCD Monitor2GW
    Discipline
    Architectural
    irneb's Discipline Details
    Occupation
    Architectural Technician and Programmer
    Discipline
    Architectural
    Using
    AutoCAD 2013
    Join Date
    Sep 2010
    Location
    Jo'burg SA
    Posts
    1,737

    Default

    It's not working for me:
    capture_07092011_080746.jpg
    I note that your total is coming from the USERS5 system variable. You probably have some lisp setting it for you. This is why I don't like doing it this way - if the field is used on a ACad which doesn't have that Lisp loaded, you get what's displayed in my screen capture.

  6. #6
    Full Member
    Using
    AutoCAD 2010
    Join Date
    Oct 2010
    Posts
    57

    Default

    Not working here also. Regen has no effect.
    I know by experience that if u use a field in a attribute, you can't get the code back that was inserted.
    Can you please give the code you inserted, and in what kind of field, sorry stil very new to this.

    Mvg John
    not native english

  7. #7
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    16,784

    Default

    I haven't looked at the drawing, but I would guess that woodman has used a field referencing a LISP Variable (or User System Variable which is updated by a LISP code) to display the total number of layouts. Since a LISP variable will only hold its value during the current drawing session (while the document namespace exists) it would need to be setq'd every time the drawing is opened for the field to display the correct value.

    I can't immediately see a way to display the total number of layouts using a field without referencing a LISP Variable or User System Variable, so would recommend the OP follows the directions I describe in post #3.
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  8. #8
    Super Moderator Cad64's Avatar
    Computer Details
    Cad64's Computer Details
    Operating System:
    Windows 7 Profesional x64
    Computer:
    XI Computers
    Motherboard:
    Asus P8Z77-V Pro
    CPU:
    Intel Core I7 3770K 4.1 Ghz Quad Core 3rd Gen
    RAM:
    24GB DDR3 @ 1333MHz
    Graphics:
    Nvidia GeForce GTX 570 1280MB GDDR5
    Primary Storage:
    SATAII 500GB 7200 RPM
    Secondary Storage:
    Western Digital My Book Studio Edition II - 2TB capacity
    Monitor:
    HPf2105 21" LCD Widescreen & Cintiq 21ux
    Discipline
    Multi-disciplinary
    Cad64's Discipline Details
    Occupation
    Freelance Digital Artist
    Discipline
    Multi-disciplinary
    Details
    In a nutshell, I create 3D models from the client's CAD files or design sketches which I then use to produce high quality rendered images. Click on the link in my signature to view my portfolio. I'm always looking for work, so let me know if you need any custom models or renders. :)
    Using
    3ds Max 2011
    Join Date
    Feb 2006
    Location
    Southern California
    Posts
    9,019

    Default

    Quote Originally Posted by sekarr24 View Post
    I need a lisp routine to count the number of layouts (layouts name will be not be specific & is random ) in a drawing from starting to end, and update the sheet no field in the title block ex: '1 of 5', '2 of 5', etc...
    I would recommend you learn about "Sheet Sets": http://heidihewett.blogs.com/my_webl...ets_Happen.pdf
    Freelance Digital Artist
    Personal Website: ( Updated 03/21/2014 ) --->
    http://www.rdeweese.com/

    "Work Smart, Not Hard"

  9. #9
    Super Member irneb's Avatar
    Computer Details
    irneb's Computer Details
    Operating System:
    Win7 Pro 64bit
    Computer:
    Antec One Hundred
    Motherboard:
    ASUS P8P67-Pro P67
    CPU:
    Intel i7 2600 @ 3.4GHz
    RAM:
    16GB-1600MHz
    Graphics:
    GeForce GT 430 (1GB)
    Primary Storage:
    Seagate1TB SATA2 - 7200rpm
    Monitor:
    Samsung 2333TN 23" 1920 x 1080 Full HD LCD Monitor2GW
    Discipline
    Architectural
    irneb's Discipline Details
    Occupation
    Architectural Technician and Programmer
    Discipline
    Architectural
    Using
    AutoCAD 2013
    Join Date
    Sep 2010
    Location
    Jo'burg SA
    Posts
    1,737

    Default

    Quote Originally Posted by johmmeke View Post
    I know by experience that if u use a field in a attribute, you can't get the code back that was inserted.
    I'm unsure what you're referring to.

    Firstly woodman's drawing has the fields inside a normal MText inside a block or simply as MText on the layout page (not attributes). Secondly I've never been unable to get at the field-code because it was in an attribute, are you perhaps referring to formula fields? Those have a tendency to become "uneditable" if they are the only thing in text/attrib/table-cell.

    Woodman's drawing (as I've stated before) loads the "Sheet # of ##" by having 2 fields:

    (1) a field pointing to the CTab system variable to get the current tab's name. Field code is "%<\AcVar ctab>%"
    (2) a field pointing to a Diesel expression simply retrieving the USERS5 system variable. Field code is "%<\AcDiesel $(getvar,users5)>%".

    If you're referring to the Date, Issue Date, Scale and Sheet Size, they are respectively: "%<\AcVar CreateDate \f "d MMMM yyyy">%"; "%<\AcVar Date \f "dd.MM.yyyy">%"; "%<\AcExpr ((1/%<\AcVar PlotScale \f "%lu2%qf2816">%)*1000/%<\AcObjProp Object(%<\_ObjId 2124506408>%).CustomScale \f "%lu2%qf2816">%) \f "%lu2%pr0">%" and "%<\AcVar.17.0 Lisp.ccc_sheet>%".

    I've got a problem with the last one which gets its value from a lisp variable (which on my PC is nil), same as the USERS5 which is "" (blank text). It might have worked if woodman also attached the LSP which sets/creates these 2.

  10. #10
    Luminous Being dbroada's Avatar
    Computer Details
    dbroada's Computer Details
    Operating System:
    Windows 7 Professional
    Computer:
    Dell
    CPU:
    Intel Xeon E5-1603@2,80GHz
    RAM:
    4GB
    Graphics:
    NVIDA Quadro K600
    Monitor:
    DELL 23" & SAMSUNG 21"
    Discipline
    Electro/Mech
    dbroada's Discipline Details
    Occupation
    Design Engineer
    Discipline
    Electro/Mech
    Using
    Electrical 2013
    Join Date
    Nov 2005
    Location
    Sussex, UK
    Posts
    5,507

    Default

    Registered forum members do not see this ad.

    could it be that Woodman's is a function of Civil? I know electrical has some automatic page numbering and other reference information built in.
    "That's it. It's one thing for a ghost to terrorize my children, but quite another for him to play my Theremin." Homer Simpson
    "Everything in drafting is logical. Except what isn’t." - Gavin Guile. (from the Lightbringer series of books by Brent Weeks)

    Dave

Similar Threads

  1. layouts are not updating
    By danblue in forum AutoCAD Drawing Management & Output
    Replies: 1
    Last Post: 30th Jul 2010, 08:46 am
  2. Best block counting method?
    By JoeC in forum AutoCAD General
    Replies: 18
    Last Post: 26th Aug 2009, 03:32 pm
  3. Updating title blocks automatically
    By LEODAVINCI in forum AutoCAD Drawing Management & Output
    Replies: 0
    Last Post: 15th Oct 2007, 04:32 pm
  4. Title Block, Layouts....
    By versegi in forum AutoCAD Beginners' Area
    Replies: 1
    Last Post: 16th May 2007, 02:04 pm
  5. Title block updating
    By c1iff in forum AutoCAD Beginners' Area
    Replies: 6
    Last Post: 1st Jun 2006, 04:36 am

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts