Author Topic: Modify Existing Layer Properties  (Read 1426 times)

0 Members and 1 Guest are viewing this topic.

GDF

  • Water Moccasin
  • Posts: 2081
Modify Existing Layer Properties
« on: February 20, 2017, 01:21:19 PM »
I can not get the line type to change.
Example:  (MakeModifyLayer "VP" 5 "HIDDEN" 0 T 0 "Vport Boundary Layer")
Yes, the line type is loaded.

Thanks for any help.

Code: [Select]
;;  Modified by CAB , apologies to Lee for the hack.
;;  Make or Modify a layer

(defun MakeModifyLayer ( name colour linetype lineweight willplot bitflag description / ent elst layer)
  ;; © Lee Mac 2010
  ;;  06/14/2011 CAB added ability to modify existing layer data
  (if (setq ent (tblobjname "LAYER" name))
    (progn
      (setq elst (entget ent)
            elst (subst (cons 6 (if (and linetype (tblsearch "LTYPE" linetype))
                                       linetype "CONTINUOUS")) (assoc 70 elst) elst)
            elst (if (assoc 62 elst)
                   (subst (cons 62 (if (and colour (< 0 (abs colour) 256)) colour 7)) (assoc 62 elst) elst)
                   (append elst (list (cons 62 (if (and colour (< 0 (abs colour) 256)) colour 7))))
                 )
            elst (if (assoc 70 elst) (subst (cons 70 bitflag) (assoc 70 elst) elst)
                   (append elst (list (cons 70 bitflag))))
            elst (subst (cons 290 (if willplot 1 0)) (assoc 290 elst) elst)
            elst (subst (cons 370
                          (if (minusp lineweight) -3
                            (fix
                              (* 100
                                 (if (and lineweight (<= 0.0 lineweight 2.11)) lineweight 0.0)
                              )
                             )
                          )
                        )
                     (assoc 370 elst) elst)
      )
      (entmod elst)
      (if (and description (setq layer (vlax-ename->vla-object ent)))
            (if (vlax-property-available-p layer 'Description)
              (vla-put-Description layer description)
            )
      )
    )
    (entmake
      (append
        (list
          (cons 0 "LAYER")
          (cons 100 "AcDbSymbolTableRecord")
          (cons 100 "AcDbLayerTableRecord")
          (cons 2  name)
          (cons 70 bitflag)
          (cons 290 (if willplot 1 0))
          (cons 6
            (if (and linetype (tblsearch "LTYPE" linetype))
              linetype "CONTINUOUS"
            )
          )
          (cons 62 (if (and colour (< 0 (abs colour) 256)) colour 7))
          (cons 370
            (if (minusp lineweight) -3
              (fix
                (* 100
                  (if (and lineweight (<= 0.0 lineweight 2.11)) lineweight 0.0)
                )
              )
            )
          )
        )
        (if description
          (list
            (list -3
              (list "AcAecLayerStandard" (cons 1000 "") (cons 1000 description))
            )
          )
        )
      )
    )
  ) ; endif
)
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: Modify Existing Layer Properties
« Reply #1 on: February 20, 2017, 01:33:45 PM »
After a cursory glance, this:
Code: [Select]
(subst (cons 6 (if (and linetype (tblsearch "LTYPE" linetype))
                                       linetype "CONTINUOUS")) (assoc 70 elst) elst)

Should be:
Code: [Select]
(subst (cons 6 (if (and linetype (tblsearch "LTYPE" linetype))
                                       linetype "CONTINUOUS")) (assoc 6 elst) elst)

GDF

  • Water Moccasin
  • Posts: 2081
Re: Modify Existing Layer Properties
« Reply #2 on: February 20, 2017, 01:50:14 PM »
Thank you Lee.
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

GDF

  • Water Moccasin
  • Posts: 2081
Re: Modify Existing Layer Properties
« Reply #3 on: February 27, 2017, 10:50:32 AM »
If you go from one cad standard to another Lee's modify layer routine works fantastic. Its very simple to change those hard to modify block attributes. Here is an example of what I do:

Code: [Select]
;;changing layer standard to the following:
(defun C:FixAtt ()
    (MakeModifyLayer "A-SYMB-ROOM" 3 "continuous" 0.30 T 0 "Room Name Symbol Mark")
    (MakeModifyLayer "A-ROOM-NOTE" 2 "continuous" 0.20 T 0 "Room Note")
    (MakeModifyLayer "A-SYMB-DOOR" 30 "continuous" 0.15 T 0 "Door Symbol Mark")
    (MakeModifyLayer "A-SYMB-WDW" 30 "continuous" 0.15 T 0 "Window Symbol Mark")
    (MakeModifyLayer "A-SYMB-WDWT" 250 "continuous" 0.15 T 0 "Window Symbol Hidden Mark")

  (command "insert" (strcat "SYMRM" "=" ARCH#CUSF "Builders Plan Service/Syms/Arch_syms/" "SYMRM") ^c^c)
  (if (/= (ssget "x" '((2 . "SYMRM"))) nil)
    (command "_ATTSYNC" "select" (ssget "x" '((2 . "SYMRM"))) "yes"))
 
  (command "insert" (strcat "SYMDR" "=" ARCH#CUSF "Builders Plan Service/Syms/Arch_syms/" "SYMDR") ^c^c)
  (if (/= (ssget "x" '((2 . "SYMDR"))) nil)
    (command "_ATTSYNC" "select" (ssget "x" '((2 . "SYMDR"))) "yes"))

  (command "insert" (strcat "SYMWDW" "=" ARCH#CUSF "Builders Plan Service/Syms/Arch_syms/" "SYMWDW") ^c^c)
  (if (/= (ssget "x" '((2 . "SYMWDW"))) nil)
    (command "_ATTSYNC" "select" (ssget "x" '((2 . "SYMWDW"))) "yes"))

  (command "insert" (strcat "SYMWDW2" "=" ARCH#CUSF "Builders Plan Service/Syms/Arch_syms/" "SYMWDW2") ^c^c)
  (if (/= (ssget "x" '((2 . "SYMWDW2"))) nil)
    (command "_ATTSYNC" "select" (ssget "x" '((2 . "SYMWDW2"))) "yes")) 

  (princ)
)

Thanks again Lee
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Modify Existing Layer Properties
« Reply #4 on: February 27, 2017, 11:21:00 AM »
Gary,

Just a quick look, but I think your code could be simplified to this.

Code - Auto/Visual Lisp: [Select]
  1. (defun c:fixatt (/ ss)
  2.   (makemodifylayer "A-SYMB-ROOM" 3 "continuous" 0.30 t 0 "Room Name Symbol Mark")
  3.   (makemodifylayer "A-ROOM-NOTE" 2 "continuous" 0.20 t 0 "Room Note")
  4.   (makemodifylayer "A-SYMB-DOOR" 30 "continuous" 0.15 t 0 "Door Symbol Mark")
  5.   (makemodifylayer "A-SYMB-WDW" 30 "continuous" 0.15 t 0 "Window Symbol Mark")
  6.   (makemodifylayer "A-SYMB-WDWT" 250 "continuous" 0.15 t 0 "Window Symbol Hidden Mark")
  7.   (foreach block '("SYMRM" "SYMDR" "SYMWDW" "SYMWDW2")
  8.     (command "_.insert" (strcat block "=" arch#cusf "Builders Plan Service/Syms/Arch_syms/" block))
  9.     (if (setq ss (ssget "_x" (list (cons 2 block))))
  10.       (command "_ATTSYNC" "select" ss "yes")
  11.     )
  12.   )
  13.   (princ)
  14. )
« Last Edit: February 27, 2017, 11:48:56 AM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

GDF

  • Water Moccasin
  • Posts: 2081
Re: Modify Existing Layer Properties
« Reply #5 on: February 27, 2017, 11:31:46 AM »
Thanks Ron
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

ChrisCarlson

  • Guest
Re: Modify Existing Layer Properties
« Reply #6 on: February 27, 2017, 11:39:59 AM »
Just a suggestion, that routine from Lee is quite old and I think he does this on his new routines but I would add the prefix LM: to MakeModifyLayer.

Code - Auto/Visual Lisp: [Select]
  1. LM:MakeModifyLayer

This will prevent any potential future routines from having a conflict.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Modify Existing Layer Properties
« Reply #7 on: February 27, 2017, 12:00:59 PM »
Good point.

Also need to thank Alan
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64