Author Topic: MakeLayer subroutine Was working but now not working  (Read 2303 times)

0 Members and 1 Guest are viewing this topic.

HasanCAD

  • Swamp Rat
  • Posts: 1420
MakeLayer subroutine Was working but now not working
« on: August 04, 2015, 04:01:18 AM »
This subroutine was working great but now does not create the layer.
Code - Auto/Visual Lisp: [Select]
  1. (defun MakeLayer (name colour linetype lineweight willplot bitflag
  2.                   description)
  3.   ;; © Lee Mac 2010
  4.   ;; (MakeLayer name colour linetype lineweight willplot bitflag description )
  5.   ;; Specifications:
  6.   ;; Description        Data Type        Remarks
  7.   ;; -----------------------------------------------------------------
  8.   ;; Layer Name          STRING          Only standard chars allowed
  9.   ;; Layer Colour        INTEGER         may be nil, -ve for Layer Off, Colour < 256
  10.   ;; Layer Linetype      STRING          may be nil, If not loaded, CONTINUOUS.
  11.   ;; Layer Lineweight    REAL            may be nil, 0 <= x <= 2.11
  12.   ;; Plot?               BOOLEAN         T = Plot Layer, nil otherwise
  13.   ;; Bit Flag            INTEGER         0=None, 1=Frozen, 2=Frozen in VP, 4=Locked
  14.   ;; Description         STRING          may be nil for no description
  15.   ;; Function will return list detailing whether layer creation is successful.
  16.   (or
  17.     (tblsearch "LAYER" name)
  18.     (entmake
  19.       (append
  20.         (list
  21.           (cons 0 "LAYER")
  22.           (cons 100 "AcDbSymbolTableRecord")
  23.           (cons 100 "AcDbLayerTableRecord")
  24.           (cons 2 name)
  25.           (cons 70 bitflag)
  26.           (cons 290
  27.                 (if willplot
  28.                   1
  29.                   0
  30.                 )
  31.           )
  32.           (cons 6
  33.                 (if (and linetype (tblsearch "LTYPE" linetype))
  34.                   linetype
  35.                   "CONTINUOUS"
  36.                 )
  37.           )
  38.           (cons 62
  39.                 (if (and colour (< 0 (abs colour) 256))
  40.                   colour
  41.                   7
  42.                 )
  43.           )
  44.           (cons 370
  45.                 (fix (* 100
  46.                         (if (and lineweight (<= 0.0 lineweight 2.11))
  47.                           lineweight
  48.                           0.0
  49.                         )
  50.                      )
  51.                 )
  52.           )
  53.         )
  54.         (if description
  55.           (list (list -3
  56.                       (list "AcAecLayerStandard"
  57.                             (cons 1000 "")
  58.                             (cons 1000 description)
  59.                       )
  60.                 )
  61.           )
  62.         )
  63.       )
  64.     )
  65.   )
  66. )
  67.  
  68. (setq ViewPortTrgtLyr "G-ANNO-VPRT-NPLT") ;Change Target Layer
  69. (MakeLayer ViewPortTrgtLyr 9 "Continuous" 0.25 NIL 0 "NO PLOT VIEW PORT LINE ")

Tharwat

  • Swamp Rat
  • Posts: 707
  • Hypersensitive
Re: MakeLayer subroutine Was working but now not working
« Reply #1 on: August 04, 2015, 04:27:33 AM »
You need to add the regapp before the description like this:

Code - Auto/Visual Lisp: [Select]
  1. (if description
  2.           (progn
  3.             (regapp "AcAecLayerStandard")
  4.             (list (list -3
  5.                         (list "AcAecLayerStandard"
  6.                               (cons 1000 "")
  7.                               (cons 1000 description)
  8.                               )
  9.                         )
  10.                   )
  11.             )
  12.           )
  13.  

HasanCAD

  • Swamp Rat
  • Posts: 1420
Re: MakeLayer subroutine Was working but now not working
« Reply #2 on: August 04, 2015, 04:45:52 AM »
Thanks Tharwat

Tharwat

  • Swamp Rat
  • Posts: 707
  • Hypersensitive
Re: MakeLayer subroutine Was working but now not working
« Reply #3 on: August 04, 2015, 06:35:34 AM »
You're welcome.

JohnK

  • Administrator
  • Seagull
  • Posts: 10603
Re: MakeLayer subroutine Was working but now not working
« Reply #4 on: August 04, 2015, 09:30:56 AM »
I just thought I'd post this...just trolling by and thought I'd offer this up too. I found this in my old files.

Code - Auto/Visual Lisp: [Select]
  1. (defun make-or-modify-layer (LNAM$ LCLR# LTYP$ LWGT# #PLOT / #prog)
  2.    ;;
  3.    ;; Ex:
  4.    ;; (make-or-modify-layer "Test-Layer" 1 "Continuous" 14 1)
  5.    ;;  > create the layer
  6.    ;; (make-or-modify-layer "Test-Layer" 1 "Continuous" 7 1)
  7.    ;;  > would override the current layer def.
  8.    ;; (make-or-modify-layer "Test-Layer" 7 "Continuous" 14 0)
  9.    ;;  > would override the current layer def.
  10.    ;;
  11.    ;; By: John K
  12.    ;;
  13.  
  14.   (if (null (tblsearch "layer" LNAM$))
  15.     (set '#prog (lambda ( x ) (entmake x)))
  16.     (set '#prog (lambda (x / ent y)
  17.                   (setq ent (entget (tblobjname "LAYER" LNAM$)))
  18.                   (foreach y x
  19.                            (if (not (member (car y) '(0 100 2)))
  20.                              (setq ent (subst y (assoc (car y) ent) ent))))
  21.                   (entmod ent) )))
  22.   (#prog
  23.    (list
  24.      (cons 0   "LAYER")
  25.      (cons 100 "AcDbSymbolTableRecord")
  26.      (cons 100 "AcDbLayerTableRecord")
  27.      (cons 2    LNAM$)
  28.      (cons 6    LTYP$)
  29.      (cons 62   LCLR#)
  30.      (cons 70   0)
  31.      (cons 290  #PLOT)
  32.      (cons 370  LWGT#)
  33.      )
  34.    )
  35.  (princ)
  36.  )
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: MakeLayer subroutine Was working but now not working
« Reply #5 on: August 04, 2015, 12:26:33 PM »
This may also be a helpful post: Creating Layers using Entmake

HasanCAD

  • Swamp Rat
  • Posts: 1420
Re: MakeLayer subroutine Was working but now not working
« Reply #6 on: August 05, 2015, 07:28:43 AM »
Code: [Select]
[quote author=John Kaul (Se7en) link=topic=49891.msg550742#msg550742 date=1438695056]
I just thought I'd post this...just trolling by and thought I'd offer this up too. I found this in my old files.
...
[/quote]
Thanks John

This may also be a helpful post: Creating Layers using Entmake
Thanks LEE