Jump to content

Sheet Numbering with AutoLISP, Diesel, macros, whatever you want to call it.


Recommended Posts

Posted

Let me preface this by saying that I know this is better handled with a sheet set manager, but it will be nearly impossible to get 30+ drafters to use that.

 

We are trying to automate the sheet numbering in our drawings. Right now, we rename the tabs to something like "01-FloorPlan" and "02-Rigging". I know about calling the CTAB variable to return the name of the tab in a field, but I want to limit what is returned to the first two characters only (i.e. the numerical values). I found a diesel expression that has part of what I was looking for:

 

$(substr,$(getvar,ctab),2)

 

This returns the CTAB value starting at the second character and includes anything after that. How can I change this to return only the first two characters?

 

Also, I'm going to add a line to the acaddoc.lsp to set a variable to return the value of (length (layoutlist)) to give me the the total count of the layout tabs. I have used this:

 

(setvar "useri1" (length (layoutlist)))

 

but it only returns a single digit if the layout quantity is less than 10. When everything is said and done, I'd like the field to display "01 OF 08" so it will show the numeric value as a two digit number all of the time.

 

Any and all help is greatly appreciated.

Posted

Guessing,

 

$(substr,$(getvar,ctab)[color="blue"],1[/color],2)

 

(setvar "[color="blue"]users1[/color]"
       (strcat (nth (Strlen (Setq str (itoa (length (layoutlist)))))
                    '(x "0" ""))
               str))

Posted

For your first question

$(substr,$(getvar,ctab),1,2)

will give you the first 2 digits and

$(substr,$(getvar,ctab),3)

will give you the remainder of the tab contents if you would want to use that for the drawing title/description. Sorry I can't help with the second bit

Posted
.... I know this is better handled with a sheet set manager, but it will be nearly impossible to get 30+ drafters to use that.

 

This is more or less a rhetorical question, but.............why is it impossible?????

 

There is really not that much to "learn"

What we did was create a template DST file, with standard custom field names if needed

Copy this .DST file to each subsequent job, and copy the fields from the last job into the current job's title blocks.

Edit the properties in the SS, and you're done.

I know the majority of users would have a hard time setting up one from scratch each project, so that is why we don't do that.

 

 

Have a good weekend all!

Posted

here is a very simple way to have 01-09 10 etc also have a look at Lee-macs parsing numbers lisp.

 

; if less than 10
(if (< (car dwgnum) 10.0) 
     (setq newstr2 (strcat dwgname "-D0"  (rtos sheetnum 2 0)))
     (setq newstr2 (strcat dwgname "-D"  (rtos sheetnum 2 0)))
)

Posted

Just another I have read the layout name and the update the sheet title block with this dwg Number if you want. Basicly once you have a lisp its easy to make it do more title block stuff. I have one that changes 20 items in a title block.

Posted
This is more or less a rhetorical question, but.............why is it impossible?????

 

Because I've only been with this company for two weeks and have NO influence at all on what they do. I brought up using XREFs and was nearly crucified for mentioning it. If it were up to me, I would be using either SolidWorks or Inventor instead of AutoCAN'T, but I was told to not to get my hopes up about either one of those.

Posted
Because I've only been with this company for two weeks and have NO influence at all on what they do. I brought up using XREFs and was nearly crucified for mentioning it. If it were up to me, I would be using either SolidWorks or Inventor instead of AutoCAN'T, but I was told to not to get my hopes up about either one of those.

 

This too will pass. While you were the ramrod at the old job, you are a rookie on this squad.

Obviously they know you know your stuff, or you wouldn't have been spirited away from

your old place of indenture.

Don't rock the boat, let them get to know your strengths, prove to the powers that be that you are

a valuable new member of the team, with credible input for consideration.

You are about to get super busy, so nobody is going to entertain notions of making

all 30 of the core draftspeople leap through hoops of fire, on short notice.

Get the big job to which you previously alluded under your belt, and out the door.

 

Down the road, at a a time when work is light, making folks more receptive, take one of those horribly bloated drawings

and fix it using xrefs, run -purge and audit, and streamline it as much as you possibly can. By then you will know who to approach.

Optimize then demonstrate. :beer:

Posted (edited)

UPDATE (edited):

 

I've abandoned the idea of forcing the sheet quantity to always be two digits. I've been told that most of our drawing sets will be less than 10 sheets (typically around eight), so this really isn't a big deal.

 

However, every time the number of layouts change, I have to re-run the macro to set the useri1 variable to the correct count and then I have to regen the drawing for the field to update. I'd like to combine both of these operations into one command. Ideally I'd like it update the variable and regen the drawing each time I invoke the regen command (typing RE or hitting a button). I've tried to change the macro for the REGEN command to ^C^CSQTY;_regen, ^C^C_SQTY;_regen or ^C^_regen;_SQTY, and nothing seems to be working.

 

I've seen other threads on other forums where people are combining multiple macros into one button, but they aren't real clear on how to do it. Would anyone mind taking a stab at this one?

 

Thanks!

Edited by SuperCAD
Posted

Are you running LT ? as its easy with lisp you just make a list of layout names take length-1 (model) = no of tabs. Only rule to using this is no junk layouts. You can though remove say layouts with certain names just a bit more complicated.

Posted

I'm running full ACAD 2012/2013. I'm not too skilled in LISP or macros. I'm just starting out with this.

Posted

Have a read of this should do what you want. Just change the block name and tag names.

 

; change the 410 to layout name

;;-------------------=={ Parse Numbers }==--------------------;;
;;                                                            ;;
;;  Parses a list of numerical values from a supplied string. ;;
;;------------------------------------------------------------;;
;;  Author: Lee Mac, Copyright © 2011 - www.lee-mac.com       ;;
;;------------------------------------------------------------;;
;;  Arguments:                                                ;;
;;  s - String to process                                     ;;
;;------------------------------------------------------------;;
;;  Returns:  List of numerical values found in string.       ;;
;;------------------------------------------------------------;;

(defun LM:ParseNumbers ( s )
 (
   (lambda ( l )
     (read
       (strcat "("
         (vl-list->string
           (mapcar
             (function
               (lambda ( a b c )
                 (if
                   (or
                     (< 47 b 58)
                     (and (= 45 b) (< 47 c 58) (not (< 47 a 58)))
                     (and (= 46 b) (< 47 a 58) (< 47 c 58))
                   )
                   b 32
                 )
               )
             )
             (cons nil l) l (append (cdr l) (list nil))
           )
         )
         ")"
       )
     )
   )
   (vl-string->list s)
 )
)

;(defun ah:sheetupdate1 (ss1 lay plotabs tabname dwgname)
(defun ah:sheetupdate1 ()
(setq doc (vla-get-activedocument (vlax-get-acad-object)))

(vlax-for lay (vla-get-Layouts doc)
 (setq plotabs (cons (vla-get-name lay) plotabs))
)

(setq len (length plotabs))
(setq tabsqty (- len 1)) ; remove model from number of layouts
(setq x 0)
(setq bname "DA1DRTXT") ; title block name
(repeat len
 (setq tabname (nth x plotabs))
 (if (/= tabname "Model")
   (progn
     (setvar "ctab" tabname)

     (setq ss1 (ssget "x"  (list (cons 0 "INSERT") (cons 2 bname)(cons 410 tabname))))
     (setq dwgnum (Lm:parsenumbers tabname))
     (setq sheetnum (car dwgnum))
     (setq oldtag1 "SHT_NO") ;attribute tag name
     (setq newstr1 (rtos sheetnum 2 0))

     (setq oldtag3 "SHT_QTY") ;attribute tag name
     (setq newstr3 tabsqty)

; if less than 10
(if (< (car dwgnum) 10.0) 
     (setq newstr2 (strcat dwgname "-D0"  (rtos sheetnum 2 0)))
     (setq newstr2 (strcat dwgname "-D"  (rtos sheetnum 2 0)))
)
     (foreach att (vlax-invoke (vlax-ename->vla-object (ssname SS1 0 )) 'getattributes)
       (if (= oldtag1 (strcase (vla-get-tagstring att)))
       (vla-put-textstring att newstr1) ; change attribute value
       ) ; end if

        (if (= oldtag3 (strcase (vla-get-tagstring att)))
       (vla-put-textstring att newstr3) ; change attribute value
       ) ; end if

      ) ; end foreach
   ) ; end progn
) ; end if
(setq x (+ x 1))
) ; end repeat
(setq ss1 nil)  
) ; end defun ah

(ah:sheetupdate1)

(princ)

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...