Jump to content

Customize a polyline with a layer and width make it into a toolpalett


Recommended Posts

Posted

Wanting to customize a p line to a certain layer. Have it on it's own tool pallett autocad 2004

  • Replies 39
  • Created
  • Last Reply

Top Posters In This Topic

  • freshfresh

    18

  • alanjt

    14

  • Lee Mac

    7

  • lpseifert

    1

Top Posters In This Topic

Posted

How about putting a call to something like this in your macro box:

 

(defun c:pline2 (/ *error* lay wid doc oLay pt)

 (setq lay "test" ) ;; Layer

 (setq wid 1.5) ;; Width

 (defun *error* (e)
   (and oLay (setvar "CLAYER" oLay))
   (and doc  (vla-EndUndoMark doc))
   (or (wcmatch (strcase e) "*BREAK,*CANCEL*,*EXIT*")
       (princ (strcat "\n** Error: " e " **")))
   (princ))

 (setq oLay (getvar 'CLAYER))


 (if (setq pt (getpoint "\nSpecify Start Point: "))
   (progn        
     (vla-StartUndoMark (setq doc (vla-get-ActiveDocument
                                    (vlax-get-acad-object))))
     
     (or (tblsearch "LAYER" lay)
         (vla-add (vla-get-layers doc) lay))

     (setvar "CLAYER" lay)
     (command "_.pline" pt "_W" wid wid)
     (while (eq 1 (logand (getvar "CMDACTIVE") 1)) (command pause))
     (setvar "CLAYER" oLay)
     (vla-EndUndoMark doc))
   
   (princ "\n*Cancel*"))

 (princ))

^C^C(c:pline2)

Posted

the layers are as followed : MAJOR width .02, minor width .01

Posted

ok i am having a hard time using this not working as planed.

Posted
ok i am having a hard time using this not working as planed.

 

What part is not working?

Posted

I can get it to work on my station.

Posted

As a very simple alternative, you could create the pline on the layer you want, drag into tool palettes, then just edit command string to this:

^C^C(setvar "plinewid" 0.01) _pline

 

Then you get the width you want, and it creates/sets the layer you want. The only drawback is the width will be 0.01 when you exit.

 

I only mention this option because you said Tool Palettes originally.

Posted
I can get it to work on my station.

 

So it works?

 

If not, what error does it throw?

Posted
As a very simple alternative, you could create the pline on the layer you want, drag into tool palettes, then just edit command string to this:

^C^C(setvar "plinewid" 0.01) _pline

 

Then you get the width you want, and it creates/sets the layer you want. The only drawback is the width will be 0.01 when you exit.

 

I only mention this option because you said Tool Palettes originally.

 

i am unable to drag a pline in autocad 2004 on to the tool palett

Posted
i am unable to drag a pline in autocad 2004 on to the tool palett

 

While, I can't guarantee it will work in 04, you should just be able to select the pline, hold the right-click down and drag into tool palettes. There isn't an image of a lock in the bottom corner of your tool palettes is there?

Posted
i am unable to make it work

Could you give me a little more information. What's it doing, when you try and drag it over? Are you dragging it with the right mouse button?

Posted

the script works but i have it on a command block. i can not put it on my tool palette window. What would i need to add in script to put a layer with this command?

Posted
the script works but i have it on a command block. i can not put it on my tool palette window. What would i need to add in script to put a layer with this command?

 

 

Crap, I was wrong. When I change it to alter the width, it will not honor the layer.

I'd just go with a lisp. I didn't try Lee's, but I'm sure it will do what you want.

Posted

i would need some help with lees i would not even know where to start could you both be kind enough to walk me through

Posted

You could use something like this:

 

(defun PlineDraw
      (#Layer #Color #Width / *error* #Doc #OldWidth #OldClayer #OldCmdecho)
 ;; error handler
 (defun *error* (#Message)
   (and #OldWidth (setvar "plinewid" #OldWidth))
   (and #OldClayer (setvar "clayer" #OldClayer))
   (and #OldCmdecho (setvar "cmdecho" #OldCmdecho))
   (and #Doc (vla-endundomark #Doc))
   (and #Message
        (not (wcmatch (strcase #Message) "*BREAK*,*CANCEL*,*QUIT*"))
        (princ (strcat "\nError: " #Message))
   ) ;_ and
 ) ;_ defun
 (cond
   ((and (snvalid #Layer)
         (numberp #Color)
         (numberp #Width)
    ) ;_ and
    (setq #Doc (vla-get-activedocument (vlax-get-acad-object)))
    (vla-startundomark #Doc)
    (setq #OldWidth   (getvar "plinewid")
          #OldClayer  (getvar "clayer")
          #OldCmdecho (getvar "cmdecho")
    ) ;_ setq
    (or (tblsearch "layer" #Layer)
        (vla-put-color (vla-add (vla-get-layers #Doc) #Layer) #Color)
    ) ;_ or
    (setvar "cmdecho" 0)
    (setvar "clayer" #Layer)
    (setvar "plinewid" #Width)
    (command "_.pline")
    (while (not (zerop (getvar "cmdactive")))
      (command PAUSE)
    ) ;_ while
    (*error* nil)
   )
 ) ;_ cond
 (princ)
) ;_ defun

Posted

Examples:

 

(defun c:MJ (/) (and PlineDraw (PlineDraw "MAJOR" 3 0.02)) (princ))
(defun c:MN (/) (and PlineDraw (PlineDraw "MINOR" 2 0.01)) (princ))

Posted

Actually, I just realized, it will work in Tool Palettes. You just have to execute the pline command first. This would work.

"^C^C_pline \w 0.02 "

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