Author Topic: prefixing layout tabs with page number attribute value  (Read 4208 times)

0 Members and 1 Guest are viewing this topic.

FengK

  • Guest
Re: prefixing layout tabs with page number attribute value
« Reply #15 on: December 12, 2007, 06:19:09 PM »
Dan,

Made minor revision. Please see below. Btw, you're welcome.

Code: [Select]
(defun C:PREFIXSHEET (/ loName ss Tab_prefix loName2)
  (vl-load-com)
  (vlax-for objLo (vla-get-layouts
    (vla-get-activedocument (vlax-get-acad-object))
  )
    (if (and (not (= (setq loName (vla-get-name objLo)) "Model"))
     (setq ss (ssget "x"
     (list (cons 0 "INSERT")
   (cons 2 "TITLE,TITLE3")
   (cons 410 loName)
     )
;Replace "TITLE,TITLE3" with your title block name(s)
      )
     )
     (setq Tab_prefix (_Get_AttValByTag (vlax-ename->vla-object (ssname ss 0))
"SHEETNUMB"
;Replace "SHEETNUMB" with your tag string
      )
     )
     (not
       (vl-position (setq loName2 (strcat Tab_prefix " " loName))
    (layoutlist)
       )
     )
)
      (vla-put-name objLo loName2)
      (prompt
(strcat "\nSomething isn't right with layout " loName ".")
      )
    )
  )
  (prompt "\nDone.")
  (princ)
)

(defun _Get_AttTagVal (oBlk)
  (if (= (vla-get-hasattributes oBlk) :vlax-true)
    (mapcar (function (lambda (oAtt)
(list oAtt
      (vla-get-tagstring oAtt)
      (vla-get-textstring oAtt)
)
      )
    )
    (vlax-safearray->list (vlax-variant-value
    (vla-getattributes oBlk)
  )
    )
    )
  )
)

(defun _Get_AttValByTag (oBlk tag / lstAtt lstVal)
  (if (and (setq lstATV (_Get_AttTagVal oBlk))
   (setq @ (vl-position (strcase tag)
(mapcar 'strcase (mapcar 'cadr lstATV))
   )
   )
      )
    (caddr (nth @ lstATV))
  )
)

(princ)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: prefixing layout tabs with page number attribute value
« Reply #16 on: December 12, 2007, 08:30:12 PM »
Change this (cons 2 "TITLE")
to this (cons 2 "TITLE*")


Edit: Kelie beet me to it.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ELOQUINTET

  • Guest
Re: prefixing layout tabs with page number attribute value
« Reply #17 on: December 13, 2007, 11:46:20 AM »
kelie

it works great. i just have one more question. which part would i modify to say add more spaces or perhaps a dash between the prefix. I wanna play around with how it looks. Thanks again to you and cab for your help.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: prefixing layout tabs with page number attribute value
« Reply #18 on: December 13, 2007, 01:24:37 PM »
Look for this
(strcat Tab_prefix " " loName)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ELOQUINTET

  • Guest
Re: prefixing layout tabs with page number attribute value
« Reply #19 on: December 17, 2007, 09:27:02 AM »
OK I've got it working as I want but just out of curiousity. I am getting this message but it works

Something isn't right with layout Model

It does not prefix my model tab but I do want it to either. Is there anyway to get rid of this error as I don't want people thinking something went wrong when all is good.

FengK

  • Guest
Re: prefixing layout tabs with page number attribute value
« Reply #20 on: December 17, 2007, 11:54:39 AM »
Is there anyway to get rid of this error as I don't want people thinking something went wrong when all is good.

Dan,

That was a bug. Please see below.

Code: [Select]
(defun C:PREFIXSHEET (/ loName ss Tab_prefix loName2)
  (vl-load-com)
  (vlax-for objLo (vla-get-layouts
    (vla-get-activedocument (vlax-get-acad-object))
  )
    (if (and (not (= (setq loName (vla-get-name objLo)) "Model"))
     (setq ss (ssget "x"
     (list (cons 0 "INSERT")
   (cons 2 "TITLE,TITLE3")
   (cons 410 loName)
     )
;Replace "TITLE" with your title block name
      )
     )
     (setq Tab_prefix (_Get_AttValByTag (vlax-ename->vla-object (ssname ss 0))
"SHEETNUMB"
;Replace "SHEETNUMB" with your tag string
      )
     )
     (not
       (vl-position (setq loName2 (strcat Tab_prefix " " loName))
    (layoutlist)
       )
     )
)
      (vla-put-name objLo loName2)
      (if (/= loName "Model")
(prompt
  (strcat "\nSomething isn't right with layout " loName ".")
)
      )
    )
  )
  (prompt "\nDone.")
  (princ)
)

(defun _Get_AttTagVal (oBlk)
  (if (= (vla-get-hasattributes oBlk) :vlax-true)
    (mapcar (function (lambda (oAtt)
(list oAtt
      (vla-get-tagstring oAtt)
      (vla-get-textstring oAtt)
)
      )
    )
    (vlax-safearray->list (vlax-variant-value
    (vla-getattributes oBlk)
  )
    )
    )
  )
)

(defun _Get_AttValByTag (oBlk tag / lstAtt lstVal)
  (if (and (setq lstATV (_Get_AttTagVal oBlk))
   (setq @ (vl-position (strcase tag)
(mapcar 'strcase (mapcar 'cadr lstATV))
   )
   )
      )
    (caddr (nth @ lstATV))
  )
)

(princ)