Jump to content

Get Pline settings as current


MastroLube

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

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