Jump to content

Creating Layers with AutoLisp


sachindkini

Recommended Posts

Hi,

 

You can use entmake and specify properties in the dxf list (look at the developer's help > DXF Reference > TABLES Section > LAYER

 

Here's an example which creates a layer named "VPORTS", color 8, unplotable

(entmake
 (list
   '(0 . "LAYER")                                ; entity name
   '(100 . "AcDbSymbolTableRecord")              ; class
   '(100 . "AcDbLayerTableRecord")               ; sub class
   '(2 . "VPORT")                                ; name
   '(70 . 0)                                     ; flag (frozen, locked, etc)
   '(62 .                                      ; color
   '(6 . "Continuous")                           ; line type
   '(290 . 0)                                    ; plotable
   '(370 . -3)                                   ; line weight
 )
)

Link to comment
Share on other sites

Use TBLOBJNAME statement to see associated list of an existing layer as per example below:

 

(entget (tblobjname "LAYER" TheLayerToList))

 

Then create a similar list with desired features and add the new layer record to database using ENTMAKE.

 

Regards,

Link to comment
Share on other sites

Creating Layers with all property (plot style, lw, discription, colour), dimension style & text style with AutoLisp

this will create layer with prperties and description

(defun _make_layer  (lname ltyp lwt col plot desc)

 (if (not (tblsearch "LAYER" lname))		  ;layer name
   (progn
     (setq new_layer
     (vla-add
       (vla-get-layers
	 (vla-get-activedocument
	   (vlax-get-acad-object)))
       lname)
    )
     )
   )
 (vla-put-description new_layer desc)		  ;description

 (vla-put-linetype
   new_layer
   (if	(tblsearch "LTYPE" ltyp)
     ltyp					  ;linetype
     "Continuous"))
 (vlax-put new_layer 'Lineweight lwt)		  ;lineweight

 (vla-put-plottable
   new_layer
   (if	plot
     :vlax-true
     :vlax-false))				  ;plottable
 (setq	accol (vla-getinterfaceobject
	(vlax-get-acad-object)
	(strcat	"AutoCAD.AcCmColor."
		(itoa (atoi (getvar "acadver")))))
)
 (vla-put-colorindex accol col)
 (vla-put-truecolor new_layer accol)		  ;color
 (vlax-release-object accol)
 )
;;Usage:

(vl-load-com)
(defun C:DEMO  ()
 (_make_layer
   "NEW_LAYER"					  ;layer name
   "CENTER"					  ;linetype
   50						  ;lineweight
   162						  ;color
   T						  ;plottable
   "The layer description is goes here"		  ;description
   )
 (princ)
 )

Link to comment
Share on other sites

  • 2 years 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...