Jump to content

lisp by mr lee mac MakeLayer (It’s possible to add dialog box to create layer)


autolisp

Recommended Posts

Dear Sir,

It’s possible to add dialog box to create layer

My query is pick architecture. Create only architecture layer

Crete layer category example

Category

1) Civil

Cv-Dim Layer

Cv-Hatch Layer

2) Architecture

Ar-Dim Layer

Ar-Hatch Layer

3) Electric

El-Dim Layer

El-Wire Layer

(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 (

(cons 370

(fix

(* 100

(if (and lineweight (

)

)

)

)

(if description

(list

(list -3

(list "AcAecLayerStandard" (cons 1000 "") (cons 1000 description))

)

)

)

)

)

)

)

(defun c:MakeLayers nil (vl-load-com)

;; © 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

;; Layer Linetype STRING may be nil, If not loaded, CONTINUOUS.

;; Layer Lineweight REAL may be nil, 0

;; 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 / lts ) (setq lts (vla-get-Linetypes (vla-get-ActiveDocument (vlax-get-acad-object))))

(mapcar 'cons (mapcar 'car lst)

(mapcar

(function

(lambda ( x )

(and (caddr x)

(or (tblsearch "LTYPE" (caddr x))

(vl-catch-all-apply 'vla-load (list lts (caddr x) "acad.lin"))

)

)

(apply 'MakeLayer x)

)

)

lst

)

)

)

'(

; Name Colour Linetype Lineweight Plot? BitFlag Description

( "CEN" 6 "CENTER" 0.18 T 0 nil )

( "DIMS" -1 nil 0.18 T 1 "Dimensions" )

( "HAT" 3 nil 0.18 T 5 nil )

( "HID" 4 "HIDDEN" 0.15 T 0 "Hidden" )

( "LOGO" 176 nil 0.09 T 0 "For Logo" )

( "OBJ" -2 nil 0.40 T 3 nil )

( "PAPER" 5 "PHANTOM" nil nil 6 nil )

( "PHAN" 6 "PHANTOM" 0.18 T 0 nil )

( "TITLE" 176 nil nil T 1 "For Title" )

( "TXT" 7 nil nil T 0 nil )

)

)

)

Edited by autolisp
changed code-tags
Link to comment
Share on other sites

Wouldn't it be easier to create all the layers you need in your template as well as have all the linetypes and text styles pre-loaded?

Link to comment
Share on other sites

There is a reason why I changed your tags to Code-tags so that the code is wrapped and scroll-able so that you don't have to scroll by a mile of lisp-text every time you check the thread. But each to his own I guess. Sorry for interfering.

Link to comment
Share on other sites

The code Lee created I am sure was meant to be one size fits all and not specific to one's needs. You will have to figure those changes out for yourself.

Link to comment
Share on other sites

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...