Jump to content
MastroLube

Get Pline settings as current

Recommended Posts

MastroLube

Hi there!

A little question.. I'm looking for a command that allow to get the object pline settings (width, layer, color, linetype, and so on) and set as current setting.

 

Have I to write a lisp to do that or autocad has a dedicate command?

 

Thanks!

 

Dennis

Share this post


Link to post
Share on other sites
rkmcswain

You can sort of do this by making a tool palette button to make a polyline, and use the settings in the button to set the layer, color, linetype, etc. (You'll have to use a macro to set the WIDTH, unless you just want to set PLINEWID instead).

 

One advantage of using a tool palette button is that the properties are only used for the command and it does NOT override defaults.

 

If you really want to SET and RETAIN settings for layer, color, linetype width, etc. - then yeah, maybe a lisp routine would be best.

Share this post


Link to post
Share on other sites
BIGAL

Try this I do apologise as to where I got it from will work with plines including width.

 

; copy a object as a command
(alert "To run just type CCMD")
(defun c:CCMD (/ ent Obj lEnt)
 (vl-load-com)
 (while (setq ent (car (nentsel "\nSelect Object: ")))
   (setq Obj (vlax-ename->vla-object ent)
         typ (cdr (assoc 0 (entget ent))))
      (cond (
          (vl-position typ '("CIRCLE" "ARC" "ELLIPSE" "SPLINE" "XLINE"))
          (comInv typ) (PropMatch Obj (entlast))
          )
         ((eq "LWPOLYLINE" typ)
          (comInv "pline") (PropMatch Obj (entlast)))
         ((eq "LINE" typ)
          (setq lEnt (entlast))
          (comInv typ)
          (foreach ent (EntCol (if lEnt lEnt (entlast)))
           (PropMatch Obj ent))))
 )
 (princ)
)
(defun PropMatch (bObj dObj)
 (or (eq 'VLA-OBJECT (type bObj))
     (setq bObj (vlax-ename->vla-object bObj)))
 (or (eq 'VLA-OBJECT (type dObj))
     (setq dObj (vlax-ename->vla-object dObj)))
 (foreach prop '(Layer Linetype LinetypeScale Color Lineweight constantwidth)
   (if (and (vlax-property-available-p bObj prop)
              (vlax-property-available-p dObj prop T))
     (vlax-put-property dObj prop
       (vlax-get-property bObj prop)))))
(defun EntCol (x / x)
 (if (setq x (entnext x))
   (cons x (EntCol x))))
(defun comInv (com)
 (command (strcat "_." com))
 (while (eq 1 (logand 1 (getvar "CMDACTIVE")))
   (command pause)))

PS changed CCMD to ZZZ a bit quicker to type.

Share this post


Link to post
Share on other sites
MastroLube

Thanks guys!

 

Can you explain a bit better (rkmcswain)? I don't know this function of tool palette button. Sounds interesting :)

 

Thanks bigal, very good code! I'll add a cycle in order to draw more lines instead of picking for everyone the source.

 

Do you think a (while (1>0) before che command to draw the pline if fine to accomplish that?

 

Thanks, sorry for the late answer

Share this post


Link to post
Share on other sites
rkmcswain

Can you explain a bit better (rkmcswain)? I don't know this function of tool palette button. Sounds interesting :)

 

 

You can add a command to a tool palette button and then assign properties to the command, such as layer, lineweight, color, etc.

When you execute this command, the properties are changed to your desired settings while the command is active, then they return to the previous settings when the command is terminated.

Share this post


Link to post
Share on other sites
BIGAL

A menu entry for a pline may look something like this similar for palette

 

^c^c^p-layer s pline3  plinewid 3.0 pline

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×