Jump to content

Layer Lisp


awill81

Recommended Posts

Hey Lee, I had one of my Jr. guys populate this. Im getting an "Error: malformed string on input" msg come up. initially i though it had something to do with the layer descriptions- so I nil all them but still get error. Cn you see where? I've hunted and can't see anything that would cause. any clue?

 

(defun MakeLayer ( name colour linetype lineweight willplot bitflag description )
 ;; © Lee Mac 2010
 (or (tblsearch "LAYER" name)
   (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
           (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))
           )
         )
       )
     )
   )
 )
)
(defun c:MakeLayers nil
 ;; © Lee Mac 2010
 ;; Specifications:
  ;; Description        Data Type        Remarks
 ;; -----------------------------------------------------------------
 ;; Layer Name          STRING          Only standard chars allowed
 ;; Layer Colour        INTEGER         may be nil, -ve for Layer Off, Colour < 256
 ;; Layer Linetype      STRING          may be nil, If not loaded, CONTINUOUS.
 ;; Layer Lineweight    REAL            may be nil, 0 <= x <= 2.11
 ;; Plot?               BOOLEAN         T = Plot Layer, nil otherwise
 ;; Bit Flag            INTEGER         0=None, 1=Frozen, 2=Frozen in VP, 4=Locked
 ;; Description         STRING          may be nil for no description
  ;; Function will return list detailing whether layer creation is successful.  
 (
   (lambda ( lst )
     (mapcar 'cons (mapcar 'car lst)
       (mapcar
         (function
           (lambda ( x )
             (apply 'MakeLayer x)
           )
         )
         lst
       )
     )
   )
  '(
    ;     Name           Colour     Linetype        Lineweight    Plot?         BitFlag         Description
    (    "BUILDING"      5          nil             0.18          T             0               nil   )
    (    "BOM"           2          nil             0.18          T             0               nil   )
    (    "Border"        7          nil             0.18          T             0               nil   )
    (    "CABLE"         3         "CABLE_LINE"     0.18          T             0               nil   )
    (    "CENTER"        6         "CENTER"         0.18          T             0               nil   )
    (    "CLOUD"         7          nil             0.18          T             0               nil   )
    (    "CONSTRUCTION"  4          nil             0.18          nil           0               nil   )
    (    "Defpoints"     7          nil             0.18          T             0               nil   )
    (    "Dim1"          1         "continuous"     0.18          T             0               nil   )
    (    "ENGNOTE"       33         nil             0.18          T             1               nil   )
    (    "ENGSTAMP"      2          nil             0.18          T             0               nil   )
    (    "Equip"         5          nil             0.18          T             0               nil   )
    (    "Exist"         33         nil             0.18          T             0               nil   )
    (    "FENCE"         3         "FENCELINE3"     0.18          T             0               nil   )
    (    "FUTURE"        8         "PHANTOM"        0.18          T             0               nil   )
    (    "Graph"         6          nil             0.18          T             0               nil   )
    (    "GRID"          1          DOT             0.18          T             0               nil   )
    (    "HVAC"          120        nil             0.18          T             0               nil   )
    (    "LEASE          33        "PHANTOM"        0.18          T             0               nil   )
    (    "PILES"         2          nil             0.18          T             0               nil   )
    (    "PIPE AG"       6          nil             0.18          T             0               nil   )
    (    "PIPE UG"       6         "HIDDEN"         0.18          T             0               nil   )
    (    "POWERLINE"     3         "POWER_LINE"     0.18          T             0               nil   )
    (    "RAILROAD"      3          nil             0.18          T             0               nil   )
    (    "ROAD"          33         nil             0.18          T             0               nil   )
    (    "ROW"           3          nil             0.18          T             0               nil   )
    (    "SKID"          33        "PHANTOM"        0.18          T             0               nil   )
    (    "Steel"         11         nil             0.18          T             0               nil   )
    (    "SURVEY"        6          nil             0.18          T             0               nil   )
    (    "SYMBOL"        1          nil             0.18          T             0               nil   )
    (    "Telephone"     3         "TELE_LINE"      0.18          T             0               nil   )
    (    "Text"          2          nil             0.18          T             0               nil   )
    (    "Top_Worx"      3          nil             0.18          T             0               nil   )
    (    "Viewl"         2          nil             0.00          nil           0               nil   )
    (    "Water"         3         "WATER_LINE"     0.18          T             0               nil   )
   )
 )
)

Link to comment
Share on other sites

  • Replies 45
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    18

  • N_461

    15

  • alanjt

    8

  • antistar

    2

Top Posters In This Topic

BEAUTY, THANKS MAN! I CANT BELEIVE I MISSED THAT.

Yah I really need to learn the basics of VILDE. Im sure theres a VLIDE For Dummies kicking around.....

Link to comment
Share on other sites

BEAUTY, THANKS MAN! I CANT BELEIVE I MISSED THAT.

Yah I really need to learn the basics of VILDE. Im sure theres a VLIDE For Dummies kicking around.....

 

No worries :)

 

Regarding VLIDE: its not too difficult - even if you just use it for the syntax highlighting.

 

Quick Start Guide:

 

Open AutoCAD, Type VLIDE at the command line, Go to File > New File (or Ctrl+N), Paste the code from your above post and you will immediately see the mistake :)

Link to comment
Share on other sites

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...