Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Creation of Revision Layers

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
heblikar.chaitanya45
203 Views, 2 Replies

Creation of Revision Layers

Hi All,

I have attached lisp code. I am facing the problem which I mentioned below.
I am trying to create Rev layers (rev1, rev2 and so on) whenever the drawing comes for revision. The code is working fine in creating the layer. But the lineweight what I have mentioned in the code i.e. 50/0.5mm is not getting set. Additionally a prompt appears with list to select an option, I have to press ESC to exit from the coede. So I need anyone of you to debug the code and provide me final lisp file. I will be thankful to this forum.

Regards,

Chaitanya 

2 REPLIES 2
Message 2 of 3

If you're going to do all those property assignments in separate Layer commands, then you need to finish each one:

 

(if (tblsearch "LAYER" newLayerName)
  (progn
    (command "_.LAYER" "_thaw" newLayerName "") ;; Thaw if layer already exists
    (command "_.LAYER" "_set" newLayerName "") ;; Make it current
  )
  (progn
;; Create new layer with specific properties
    (command "_.LAYER" "_make" newLayerName "")
;; Set layer properties manually
    (command "_.LAYER" "_color" "cyan" newLayerName "") ;; Explicitly set color to cyan
    (command "_.LAYER" "_Lweight" "50" newLayerName "") ;; Set line weight to 0.50mm
    (command "_.LAYER" "_Ltype" "Continuous" newLayerName "") ;; Set line type to Continuous
    (command "_.LAYER" "_Plot" "yes" newLayerName "") ;; Make layer plottable
    (command "_.LAYER" "_Transparency" "0" newLayerName "") ;; Set transparency to 0
;; Make the new layer current
    (command "_.LAYER" "_set" newLayerName "")
  )
)

 

And that last command is unnecessary -- the Make option earlier will have set it current in the process, and in all those property assignments, newLayerName can be replaced with "" as the default.

 

But don't do that.  You can combine as many Layer operations in one command as you want.  And I would not bother to check whether it exists -- just Make it, and it won't matter if it already exists, and it will become current.  I would Thaw it first just in case -- it can't be made current if it's Frozen -- and it won't matter if it doesn't yet exist.

 

All the above-quoted code can be replaced with just this:

 

  (command "_.LAYER"
    "_thaw" newLayerName
    "_make" newLayerName
    "_color" "cyan" ""
    "_Lweight" "50" ""
    "_Ltype" "Continuous" ""
    "_Plot" "yes" ""
    "_Transparency" "0" ""
    ""
  )

 

Consider whether you need to do that linetype assignment.  Continuous is the default for new Layers, so it's unnecessary, unless it's possible that the Layer already exists with some other linetype, and you want to correct that.

 

Also, earlier, there's no point in checking whether Layer "0" exists -- it always does, and can't be Purged or Renamed, so there's no point in Making it [though that's permitted].  It should be Thawed just in case, but that and making it current are all you need:

(command "_.LAYER" "_thaw" "0" "_set" "0" "")

Kent Cooper, AIA
Message 3 of 3

Thank You for the code correction. It worked...

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report