Author Topic: Help with layer make command  (Read 125 times)

0 Members and 1 Guest are viewing this topic.

PM

  • Bull Frog
  • Posts: 215
Help with layer make command
« on: June 10, 2021, 10:33:22 AM »
Hi. I want to create a layer but this layer i want to be no print and freeze in layout viewport. I fix the plot no but i don't knoww how to freeze in viewport


Code - Auto/Visual Lisp: [Select]
  1.   (COMMAND "_layer" "_m" "FRAME" "_c" "212" "" "_plot" "_no" "" "")
  2.  

Thanks

PM

  • Bull Frog
  • Posts: 215
Re: Help with layer make command
« Reply #1 on: June 10, 2021, 10:51:02 AM »
I find it thanks

tombu

  • Bull Frog
  • Posts: 234
  • ByLayer=>Not0
Re: Help with layer make command
« Reply #2 on: June 10, 2021, 10:56:57 AM »
I've used Jimmy Bergmark's https://jtbworld.com/autocad-layer-toggle-freeze-lsp for years.
You can toggle a list of layers as well in a macro like:
Code: [Select]
^P(or layer-toggle-freeze(load "layer-toggle-freeze.lsp"))(layer-toggle-freeze '("Viewports" "Work"))
Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D

John Kaul (Se7en)

  • Administrator
  • Needs a day job
  • Posts: 9626
Re: Help with layer make command
« Reply #3 on: June 10, 2021, 11:03:54 AM »
You can try entmod to create your layer.

Code: [Select]
;; LAYER group codes
;; 
;; Group codes -   Description
;; 
;; 100 - Subclass marker (AcDbLayerTableRecord)
;; 
;; 2  -   Layer name
;; 
;; 70 - Standard flags (bit-coded values):
;; 1  = Layer is frozen; otherwise layer is thawed
;; 2  = Layer is frozen by default in new viewports
;; 4  = Layer is locked
;; 16 = If set, table entry is externally dependent on an xref
;; 32 = If both this bit and bit 16 are set, the externally
;;      dependent xref has been successfully resolved
;; 64 = If set, the table entry was referenced by at least
;;      one entity in the drawing the last time the drawing
;;      was edited. (This flag is for the benefit of AutoCAD
;;      commands. It can be ignored by most programs that
;;      read DXF files and need not be set by programs that
;;      write DXF files)
;; 
;; 62 - Color number (if negative, layer is off)
;; 
;; 6 - Linetype name
;; 
;; 290 - Plotting flag. If set to 0, do not plot this layer
;; 
;; 370 - Lineweight enum value
;; 
;; 390 - Hard-pointer ID/handle of PlotStyleName object

Code - Auto/Visual Lisp: [Select]
  1.            '(0 . "LAYER")
  2.            '(100 . "AcDbSymbolTableRecord")
  3.            '(100 . "AcDbLayerTableRecord")
  4.            (cons 2 ;| layername |;  )
  5.            (cons 70 ;| stuff |; )
  6.            (cons 62 ;| color number |; )
  7.            (cons 290 ;| plot |; )
  8.            (cons 6 "Continuous") ;; linetype
  9.          );_ end list
  10. );_ end entmake

TheSwamp.org (serving the CAD community since 2003)

Donate to TheSwamp.org

PM

  • Bull Frog
  • Posts: 215
Re: Help with layer make command
« Reply #4 on: June 10, 2021, 11:09:38 AM »
i use

Code - Auto/Visual Lisp: [Select]
  1.    (COMMAND "_layer" "_m" "FRAME" "_c" "212" "" "_plot" "_no" "" "")
  2. ;
  3. ;
  4. ;
  5. ;
  6. ;
  7. ;
  8. ;and at the end of the code
  9. (command "vplayer" "F" "FRAME" "a" "" )
  10. (command "setvar" "clayer" "0")
  11. (command "-linetype" "set" "Bylayer" "")
  12.  

the problem is when i create a new layout , in the new layaout viewports  this layer is not freeze

John Kaul (Se7en)

  • Administrator
  • Needs a day job
  • Posts: 9626
Re: Help with layer make command
« Reply #5 on: June 10, 2021, 11:10:45 AM »
Also, a fun routine a friend coded up once came to mind for modifying a layer. This same approach could be used to create a layer as well.

Code - Auto/Visual Lisp: [Select]
  1. (defun layerActions (actions layerName / layer laylst flags color plot)
  2. ;; SMadsen on 06-27-2003
  3. ;; 0 = no action
  4. ;; 1 = freeze
  5. ;; 2 = thaw
  6. ;; 4 = off
  7. ;; 8 = on
  8. ;; 16 = lock
  9. ;; 32 = unlock
  10. ;; 64 = plot on
  11. ;; 128 = plot off
  12. ;;
  13. ;; Simply adding the values determines the actions taken by the function. For example:
  14. ;;
  15. ;;  (layerActions (+ 8 32 64) "myLayer") will turn on "myLayer", unlock it and enable plotting (I hope).
  16. (cond ((setq layer (tblobjname "LAYER" layerName))
  17.        (setq laylst (entget layer)
  18.              flags  (cdr (assoc 70 laylst))
  19.              color  (cdr (assoc 62 laylst))
  20.              plot   (cdr (assoc 290 laylst)))
  21.        (cond ((= (logand actions 2) 2) (setq flags (logior flags 1)))
  22.              ((= (logand actions 1) 1) (setq flags (- flags (logand flags 1)))))
  23.        (cond ((= (logand actions 8) 8) (setq color (- (abs color))))
  24.              ((= (logand actions 4) 4) (setq color (abs color))))
  25.        (cond ((= (logand actions 32) 32) (setq flags (logior flags 4)))
  26.              ((= (logand actions 16) 16)(setq flags (- flags (logand flags 4)))))
  27.        (cond ((= (logand actions 64) 64) (setq plot 1))
  28.              ((= (logand actions 128) 128) (setq plot 0)))
  29.        (setq laylst (subst (cons 70 flags)(assoc 70 laylst) laylst)
  30.              laylst (subst (cons 62 color)(assoc 62 laylst) laylst)
  31.              laylst (subst (cons 290 plot)(assoc 290 laylst) laylst))
  32.        (entmod laylst)
  33.        )
  34.       )
  35. )

Fun I mean in that instead of trying to memorize magic numbers, you can use ENUMS to make your coding easier to read/write.

Code - Auto/Visual Lisp: [Select]
  1. (setq  *Freeze* 1
  2.  *Thaw* 2
  3.  *Off* 4
  4.  *On* 8
  5.  *Lock* 16
  6.  *Unlock* 32
  7.  *PlotOn* 64
  8.  *PlotOff* 128)
  9. ; the above global vars would be in the toolbox function
  10.  (layerActions (+ *On* *Unlock* *PlotOn*) "myLayer")
  11.  
TheSwamp.org (serving the CAD community since 2003)

Donate to TheSwamp.org

PM

  • Bull Frog
  • Posts: 215
Re: Help with layer make command
« Reply #6 on: June 10, 2021, 11:35:10 AM »
Thanks John Kaul