Author Topic: Adjust All Lineweights  (Read 3070 times)

0 Members and 1 Guest are viewing this topic.

CTMill

  • Newt
  • Posts: 120
Adjust All Lineweights
« on: September 22, 2009, 12:35:50 PM »
I am writing a lisp to adjust all of my lineweights by .1.  It will adjust the lineweights in the layer manager and on hard coded objects.  The lineweight adjustments are preset in the code.  It adjusts the default lineweights to the actual default value.  

I can get this to work, but it appears I have some issues.  It errors when there is too much for it to do.  I'm not good with counters and going thru lists.  Please let me know what I'm doing wrong.

Code: [Select]
(defun *alwerror* (errmes)
  (princ
    (strcat "\nAdjustment to LineWeights halted By: " errmes)
  )
  (setq layer nil)
  (setq lw nil)
  (setq lwdef nil)
  (setq deflw nil)
  (setq hardcodeobj nil)
  (setq hcobjnam nil)
  (setq hcdxf nil)
  (setq hclw nil)
  (setq hcobj nil)
  (command "undo" "end")
  (setq *alwerror* oldalwerr)
  (command "undo" "1")
  (prin1)
)
(defun C:ALW (/ Layer lw lwdef deflw hardcodeobj hcobjnam hcdxf hclw
     hcobj cnt)
  (command "undo" "g")
  (setq oldalwerr *alwerror*)
  (setq blindman (getvar "cmdecho"))
  (setvar "cmdecho" 0)
  (setq lwdef (getvar "lwdefault"))
  (setq deflw lwdef)
  (cond
    ((= deflw 25)
     (setq lwdef deflw)
    )
    ((< deflw 25)
     (progn
       (setq lwdef 25)
       (setvar "lwdefault" 25)
     )
    )
    ((> deflw 25)
     (progn
       (setq lwdef 25)
       (setvar "lwdefault" 25)
     )
    )
  )
  (vl-load-com)
  (vlax-for layer (vla-get-Layers
   (vla-get-ActiveDocument
     (vlax-get-acad-object)
   )
 )
    (setq lw (vla-get-lineweight layer))
    (cond
      ((= lw -3)
       (vla-put-lineweight layer lwdef)
      )
      ((= lw 0)
       (vla-put-lineweight layer 0)
      )
      ((= lw 5)
       (vla-put-lineweight layer 15)
      )
      ((= lw 9)
       (vla-put-lineweight layer 18)
      )
      ((= lw 13)
       (vla-put-lineweight layer 20)
      )
      ((= lw 15)
       (vla-put-lineweight layer 25)
      )
      ((= lw 18)
       (vla-put-lineweight layer 30)
      )
      ((= lw 20)
       (vla-put-lineweight layer 30)
      )
      ((= lw 25)
       (vla-put-lineweight layer 35)
      )
      ((= lw 30)
       (vla-put-lineweight layer 40)
      )
      ((= lw 35)
       (vla-put-lineweight layer 45)
      )
      ((= lw 40)
       (vla-put-lineweight layer 50)
      )
      ((= lw 50)
       (vla-put-lineweight layer 60)
      )
      ((= lw 53)
       (vla-put-lineweight layer 60)
      )
      ((= lw 60)
       (vla-put-lineweight layer 70)
      )
      ((= lw 70)
       (vla-put-lineweight layer 80)
      )
      ((= lw 80)
       (vla-put-lineweight layer 90)
      )
      ((= lw 90)
       (vla-put-lineweight layer 100)
      )
      ((= lw 100)
       (vla-put-lineweight layer 106)
      )
      ((= lw 106)
       (vla-put-lineweight layer 120)
      )
      ((= lw 120)
       (vla-put-lineweight layer 140)
      )
      ((= lw 140)
       (vla-put-lineweight layer 158)
      )
      ((= lw 158)
       (vla-put-lineweight layer 200)
      )
      ((= lw 200)
       (vla-put-lineweight layer 211)
      )
    )
  )
  (setq hardcodeobj (ssget "x"))
  (setq cnt (sslength hardcodeobj))
  (while
    (> cnt 0)
     (progn
       (setq hcobjnam (ssname hardcodeobj (- cnt 1)))
       (setq hcdxf (entget hcobjnam))
       (setq hclw (cdr (assoc 370 hcdxf)))
     )
     (cond
       ((= hclw -3)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 lwdef) (assoc 370 hcobj) hcobj))
(entmod hcobj)
       )
       ((= hclw 0)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 0) (assoc 370 hcobj) hcobj))
(entmod hcobj)
       )
       ((= hclw 5)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 15) (assoc 370 hcobj) hcobj))
(entmod hcobj)
       )
       ((= hclw 9)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 18) (assoc 370 hcobj) hcobj))
(entmod hcobj)
       )
       ((= hclw 13)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 20) (assoc 370 hcobj) hcobj))
(entmod hcobj)
       )
       ((= hclw 15)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 25) (assoc 370 hcobj) hcobj))
(entmod hcobj)
       )
       ((= hclw 18)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 30) (assoc 370 hcobj) hcobj))
(entmod hcobj)
       )
       ((= hclw 20)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 30) (assoc 370 hcobj) hcobj))
(entmod hcobj)
       )
       ((= hclw 25)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 35) (assoc 370 hcobj) hcobj))
(entmod hcobj)
       )
       ((= hclw 30)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 40) (assoc 370 hcobj) hcobj))
(entmod hcobj)
       )
       ((= hclw 35)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 45) (assoc 370 hcobj) hcobj))
(entmod hcobj)
       )
       ((= hclw 40)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 50) (assoc 370 hcobj) hcobj))
(entmod hcobj)
       )
       ((= hclw 50)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 60) (assoc 370 hcobj) hcobj))
(entmod hcobj)
       )
       ((= hclw 53)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 60) (assoc 370 hcobj) hcobj))
(entmod hcobj)
       )
       ((= hclw 60)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 70) (assoc 370 hcobj) hcobj))
(entmod hcobj)
       )
       ((= hclw 70)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 80) (assoc 370 hcobj) hcobj))
(entmod hcobj)
       )
       ((= hclw 80)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 90) (assoc 370 hcobj) hcobj))
(entmod hcobj)
       )
       ((= hclw 90)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 100) (assoc 370 hcobj) hcobj))
(entmod hcobj)
       )
       ((= hclw 100)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 106) (assoc 370 hcobj) hcobj))
(entmod hcobj)
       )
       ((= hclw 106)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 120) (assoc 370 hcobj) hcobj))
(entmod hcobj)
       )
       ((= hclw 120)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 140) (assoc 370 hcobj) hcobj))
(entmod hcobj)
       )
       ((= hclw 140)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 158) (assoc 370 hcobj) hcobj))
(entmod hcobj)
       )
       ((= hclw 158)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 200) (assoc 370 hcobj) hcobj))
(entmod hcobj)
       )
       ((= hclw 200)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 211) (assoc 370 hcobj) hcobj))
(entmod hcobj)
       )
     )
     (setq cnt (- cnt 1))
  )
  (prompt "\nAll lineweights are now roughly .1 heavier.")
  (setvar "cmdecho" blindman)
  (setq usrnam (getvar "loginname"))
  (setq dwgnam (getvar "dwgname"))
  (setq *alwerror* oldalwerr)
  (setq cnt nil)
  (setq layer nil)
  (setq lw nil)
  (setq lwdef nil)
  (setq deflw nil)
  (setq hardcodeobj nil)
  (setq hcobjnam nil)
  (setq hcdxf nil)
  (setq hclw nil)
  (setq hcobj nil)
  (setq blindman nil)
  (command "undo" "end")
  (princ)
)

<edit: code tags added>
« Last Edit: September 22, 2009, 01:23:24 PM by CAB »
Civ3d/A2K16

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Adjust All Lineweights
« Reply #1 on: September 22, 2009, 02:20:05 PM »
First off if the hard coded objects layer is locked the lisp will bomb...

What if this lisp gets run twice? Wouldn't your weights be wrong?

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

CTMill

  • Newt
  • Posts: 120
Re: Adjust All Lineweights
« Reply #2 on: September 22, 2009, 03:11:40 PM »
First off if the hard coded objects layer is locked the lisp will bomb...

What if this lisp gets run twice? Wouldn't your weights be wrong?

I didn't think about locked layers.....good point.  And I planned on adding code to grab the user and drawing name so that it will only run once in the current drawing. 

My intent is for personal use only.  I am the only one in my company that is forced to use lineweights to satisfy a client.  So making this perfect wasn't a high priority.  I'd be happy with it, if it didn't error.

I do appreciate your comments because your making me think harder about this.  Now I'm debating if I should somehow calculate the lineweight instead.  And add an option for adding or subtracting from the current lineweight. I'll see what I can do when I have more time.  Thanks, Ron!
Civ3d/A2K16

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Adjust All Lineweights
« Reply #3 on: September 22, 2009, 03:35:03 PM »
Here is something to mull over:

Code: [Select]
(defun c:test (/ e el int lw n ss ss2)
  ;;will change an object lineweight by a user amount
  ;;any highlighted objects were not changed
  (setq n   -1
ss2 (ssadd)
  )
  (if
    (and (setq ss (ssget "_x" '((-4 . ">=") (370 . 0))))
(setq int (getint "\nEnter number to add (- to subtract) from lineweight:"))
    )
     (while (setq e (ssname ss (setq n (1+ n))))
       (setq el (entget e)
     lw (cdr (assoc 370 el))
       )
       (if (not (entmod (subst (cons 370 (+ lw int)) (assoc 370 el) el)))(ssadd e ss2))
     )
  )
  (sssetfirst nil ss2)
  (princ)
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

CTMill

  • Newt
  • Posts: 120
Re: Adjust All Lineweights
« Reply #4 on: September 22, 2009, 03:40:36 PM »
I will Ron.  Thank you!
Civ3d/A2K16

CTMill

  • Newt
  • Posts: 120
Re: Adjust All Lineweights
« Reply #5 on: November 16, 2009, 06:00:57 PM »
Ron,

I finally had time to make some changes based off your example.  It works without errors now.  Thank you very much!

Civ3d/A2K16

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Adjust All Lineweights
« Reply #6 on: November 18, 2009, 10:06:03 AM »
My version, not tested.
Code: [Select]
(defun C:ALW (/ usercmd DWGNAM ELIST ENAME I LOCKEDLAYERS LW LWDEF
              LWTABLE NEWLW SS USRNAM *error*)
  (defun *error* (msg)
    (if (not
          (member msg  '("console break" "Function cancelled" "quit / exit abort" "" nil)))
       (princ (strcat "\nError: " msg))
    )
    (and usercmd (setvar "CMDECHO" usercmd))
    (princ)
  ) ; end error function
  
  (vl-load-com)
  
  (command "undo" "g")
  (setq usercmd (getvar "cmdecho"))
  (setvar "cmdecho" 0)
  
  (setq lwdef 25)
  (setvar "lwdefault" 25)

  (setq lwTable (append
                  (list(list -3 lwdef))
                  '((5 15)(9 18)(13 20)(15 25)(18 30)(20 30)
                  (25 35)(30 40)(35 45)(40 50)(50 60)(53 60) (60 70)
                  (70 80)(80 90)(100 106)(120 140)(140 158)(200 211)
                 )))

  ;;  Update layer objects
  (vlax-for layer (vla-get-Layers (vla-get-ActiveDocument (vlax-get-acad-object)))
    (if (= (vla-get-lock layer) ':vlax-true)
      (setq Lockedlayers (cons (vla-get-name layer) Lockedlayers))
    )
    (setq lw (vla-get-lineweight layer))
    (if (setq newlw (cadr (assoc lw lwTable)))
       (vla-put-lineweight layer newlw)
    )
  )

  ;;  update objects with lineweight not ByLayer
  (setq ss (ssget "x"))
  (setq i -1)
  (while (setq ename (ssname ss (setq i (1+ i))))
    (if (setq newlw (cadr (assoc lw lwTable)))
       (progn
        (setq elist (entget ename))
        (setq elist (subst (cons 370 newlw) (assoc 370 elist) elist))
        (entmod elist)
       )
     )
   )

  ;;  restore locked layers
  (mapcar
    (function
      (lambda(lyrname)
        (vlax-put-property
          (vla-item
            (vla-get-Layers (vla-get-ActiveDocument (vlax-get-acad-object)))
            lyrname)
        'Lock :vlax-true))) Lockedlayers)

  
  (prompt "\nAll lineweights are now roughly .1 heavier.")
  (setq usrnam (getvar "loginname"))
  (setq dwgnam (getvar "dwgname"))
  (*error* nil)
  (command "undo" "end")
  (princ)
)
« Last Edit: November 18, 2009, 10:54:27 AM by CAB »
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.

CTMill

  • Newt
  • Posts: 120
Re: Adjust All Lineweights
« Reply #7 on: November 18, 2009, 10:38:50 AM »
I gave it a test run.  I had only one error occur.  You'll need to fix the name of the cmdecho variable.  In the beginning you use usercmd but at the end you're still using blindman.  Other than that, it works great! 

Thank you CAB for taking the time to write this code.  Now I will go see what I can learn from it.....
Civ3d/A2K16

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Adjust All Lineweights
« Reply #8 on: November 18, 2009, 10:56:01 AM »
You're welcome.
I removed that line of code from the post above. Forgot to before. It is not needed as the error routine is called before exist & sets that.
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.

CTMill

  • Newt
  • Posts: 120
Re: Adjust All Lineweights
« Reply #9 on: December 02, 2009, 02:39:03 PM »
I combined my code with yours (CAB) to save time.  This is what I ended up with and it works flawlessly for me.

Code: [Select]
;;  error handler
(defun *alwerror* (errmes)
  (princ
    (strcat "\nAdjustment to LineWeights halted By: " errmes)
  )
  (setq cnt nil)
  (setq ss nil)
  (setq blindman nil)
  (setq layer nil)
  (setq lockedlayers nil)
  (setq namelyr nil)
  (setq lyrname nil)
  (setq lw nil)
  (setq lwdef nil)
  (setq deflw nil)
  (setq hardcodeobj nil)
  (setq hcobjnam nil)
  (setq hcdxf nil)
  (setq hclw nil)
  (setq hcobj nil)
  (command "undo" "end")
  (setq *alwerror* oldalwerr)
  (command "undo" "1")
  (prin1)
)
;;  starts command and determines if the command has been run already
(defun C:ALW (/ Layer    lw       lwdef deflw     hardcodeobj
hcobjnam   hcdxf      hclw hcobj     cnt
ss    lockedlayers namelyr    lyrname
       )
  (command "undo" "g")
  (cond
    (
     (progn
       (= usrnam nil)
       (= dwgnam nil)
     )
     (c:adjustlineweights)
    )
    ((progn
       (/= usrnam nil)
       (/= dwgnam nil)
     )
     (c:onetime)
    )
  )
  (princ)
)
;;  alert if command has already been used
(defun C:onetime (/)
  (alert "\nSorry, you can only use this once.\n")
  (princ)
)
;;  update lineweights in layer manager
(defun c:adjustlineweights (/)
  (setq oldalwerr *alwerror*)
  (setq blindman (getvar "cmdecho"))
  (setvar "cmdecho" 0)
  (prompt "\nALW makes all linewights about .1 heavier.")
  (setq lwdef (getvar "lwdefault"))
  (setq deflw lwdef)
  (cond
    ((= deflw 25)
     (setq lwdef deflw)
    )
    ((< deflw 25)
     (progn
       (setq lwdef 25)
       (setvar "lwdefault" 25)
     )
    )
    ((> deflw 25)
     (progn
       (setq lwdef 25)
       (setvar "lwdefault" 25)
     )
    )
  )
  (vl-load-com)
  (vlax-for layer (vla-get-Layers
    (vla-get-ActiveDocument
      (vlax-get-acad-object)
    )
  )
    (setq lw (vla-get-lineweight layer))
    (cond
      ((= lw -3)
       (vla-put-lineweight layer lwdef)
      )
      ((= lw 0)
       (vla-put-lineweight layer 0)
      )
      ((= lw 5)
       (vla-put-lineweight layer 15)
      )
      ((= lw 9)
       (vla-put-lineweight layer 18)
      )
      ((= lw 13)
       (vla-put-lineweight layer 20)
      )
      ((= lw 15)
       (vla-put-lineweight layer 25)
      )
      ((= lw 18)
       (vla-put-lineweight layer 30)
      )
      ((= lw 20)
       (vla-put-lineweight layer 30)
      )
      ((= lw 25)
       (vla-put-lineweight layer 35)
      )
      ((= lw 30)
       (vla-put-lineweight layer 40)
      )
      ((= lw 35)
       (vla-put-lineweight layer 50)
      )
      ((= lw 40)
       (vla-put-lineweight layer 50)
      )
      ((= lw 50)
       (vla-put-lineweight layer 60)
      )
      ((= lw 53)
       (vla-put-lineweight layer 60)
      )
      ((= lw 60)
       (vla-put-lineweight layer 70)
      )
      ((= lw 70)
       (vla-put-lineweight layer 80)
      )
      ((= lw 80)
       (vla-put-lineweight layer 90)
      )
      ((= lw 90)
       (vla-put-lineweight layer 100)
      )
      ((= lw 100)
       (vla-put-lineweight layer 106)
      )
      ((= lw 106)
       (vla-put-lineweight layer 120)
      )
      ((= lw 120)
       (vla-put-lineweight layer 140)
      )
      ((= lw 140)
       (vla-put-lineweight layer 158)
      )
      ((= lw 158)
       (vla-put-lineweight layer 200)
      )
      ((= lw 200)
       (vla-put-lineweight layer 211)
      )
    )
  )
  ;;
  ;;
  ;;
  ;;
  ;;  makes a list of all locked layers
  (vlax-for layer (vla-get-Layers
    (vla-get-ActiveDocument (vlax-get-acad-object))
  )
    (if (= (vla-get-lock layer) ':vlax-true)
(setq lockedlayers (cons (vla-get-name layer) lockedlayers))
    )
  )
  ;;
  ;;
  ;;
  ;;
  ;;  unlock locked layers
    (mapcar
      (function
(lambda (namelyr)
  (vlax-put-property
    (vla-item
      (vla-get-Layers
(vla-get-ActiveDocument (vlax-get-acad-object))
      )
      namelyr
    )
    'Lock
    :vlax-false
  )
)
      )
      lockedlayers
    )
  ;;
  ;;
  ;;
  ;;
  ;;  selects all objects and changes the lineweight settings if it is hard coded
  (setq cnt -1
ss  (ssadd)
  )
  (if (setq hardcodeobj (ssget "_x" '((-4 . ">=") (370 . 0))))
    (while (setq hcobjnam (ssname hardcodeobj (setq cnt (1+ cnt))))
      (setq hcdxf (entget hcobjnam)
    hclw  (cdr (assoc 370 hcdxf))
      )
      (cond
((= hclw -3)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 lwdef) (assoc 370 hcobj) hcobj))
(entmod hcobj)
)
((= hclw 0)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 0) (assoc 370 hcobj) hcobj))
(entmod hcobj)
)
((= hclw 5)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 15) (assoc 370 hcobj) hcobj))
(entmod hcobj)
)
((= hclw 9)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 18) (assoc 370 hcobj) hcobj))
(entmod hcobj)
)
((= hclw 13)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 20) (assoc 370 hcobj) hcobj))
(entmod hcobj)
)
((= hclw 15)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 25) (assoc 370 hcobj) hcobj))
(entmod hcobj)
)
((= hclw 18)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 30) (assoc 370 hcobj) hcobj))
(entmod hcobj)
)
((= hclw 20)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 30) (assoc 370 hcobj) hcobj))
(entmod hcobj)
)
((= hclw 25)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 35) (assoc 370 hcobj) hcobj))
(entmod hcobj)
)
((= hclw 30)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 40) (assoc 370 hcobj) hcobj))
(entmod hcobj)
)
((= hclw 35)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 50) (assoc 370 hcobj) hcobj))
(entmod hcobj)
)
((= hclw 40)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 50) (assoc 370 hcobj) hcobj))
(entmod hcobj)
)
((= hclw 50)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 60) (assoc 370 hcobj) hcobj))
(entmod hcobj)
)
((= hclw 53)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 60) (assoc 370 hcobj) hcobj))
(entmod hcobj)
)
((= hclw 60)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 70) (assoc 370 hcobj) hcobj))
(entmod hcobj)
)
((= hclw 70)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 80) (assoc 370 hcobj) hcobj))
(entmod hcobj)
)
((= hclw 80)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 90) (assoc 370 hcobj) hcobj))
(entmod hcobj)
)
((= hclw 90)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 100) (assoc 370 hcobj) hcobj))
(entmod hcobj)
)
((= hclw 100)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 106) (assoc 370 hcobj) hcobj))
(entmod hcobj)
)
((= hclw 106)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 120) (assoc 370 hcobj) hcobj))
(entmod hcobj)
)
((= hclw 120)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 140) (assoc 370 hcobj) hcobj))
(entmod hcobj)
)
((= hclw 140)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 158) (assoc 370 hcobj) hcobj))
(entmod hcobj)
)
((= hclw 158)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 200) (assoc 370 hcobj) hcobj))
(entmod hcobj)
)
((= hclw 200)
(setq hcobj (entget hcobjnam))
(setq hcobj (subst (cons 370 211) (assoc 370 hcobj) hcobj))
(entmod hcobj)
)
      )
      (ssadd hcobjnam ss)
    )
  )
  ;;
  ;;
  ;;
  ;;
    ;;  restore locked layers
    (mapcar
      (function
(lambda (lyrname)
  (vlax-put-property
    (vla-item
      (vla-get-Layers
(vla-get-ActiveDocument (vlax-get-acad-object))
      )
      lyrname
    )
    'Lock
    :vlax-true
  )
)
      )
      lockedlayers
    )
  ;;
  ;;
  ;;
  ;;
  (prompt "\nLineweight adjustment is complete.")
  (setvar "cmdecho" blindman)
  (setq usrnam (getvar "loginname"))
  (setq dwgnam (getvar "dwgname"))
  (setq *alwerror* oldalwerr)
  (setq lockedlayers nil)
  (setq ss nil)
  (setq cnt nil)
  (setq layer nil)
  (setq namelyr nil)
  (setq lyrname nil)
  (setq lw nil)
  (setq lwdef nil)
  (setq deflw nil)
  (setq hardcodeobj nil)
  (setq hcobjnam nil)
  (setq hcdxf nil)
  (setq hclw nil)
  (setq hcobj nil)
  (setq blindman nil)
  (command "undo" "end")
  (princ)
)


Thanks for your help CAB!  I wouldn't have finished this without you....
Civ3d/A2K16

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Adjust All Lineweights
« Reply #10 on: December 02, 2009, 02:55:10 PM »
You're welcome. :-)
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.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Adjust All Lineweights
« Reply #11 on: December 02, 2009, 03:02:56 PM »
Just an idea here .. I noticed you reset alot of variables to nil in your error handlers ... and in the code as well ... if localizing them does not set them to nil, you could use a much more succinct way:

Code: [Select]
  (mapcar '(lambda (x) (set (read x) nil))
  '("cnt" "ss" "blindman" "layer");enclose all vars in quotes you want to set to nil
  )
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

CTMill

  • Newt
  • Posts: 120
Re: Adjust All Lineweights
« Reply #12 on: December 02, 2009, 03:25:38 PM »
ahhh.... :ugly:      that's just me illustrating how much I don't know about autolisp!  :lol:
Civ3d/A2K16