freshfresh Posted September 30, 2009 Posted September 30, 2009 Wanting to customize a p line to a certain layer. Have it on it's own tool pallett autocad 2004 Quote
Lee Mac Posted September 30, 2009 Posted September 30, 2009 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) Quote
freshfresh Posted October 1, 2009 Author Posted October 1, 2009 the layers are as followed : MAJOR width .02, minor width .01 Quote
Lee Mac Posted October 1, 2009 Posted October 1, 2009 Well the code is there for you to amend how you wish. :wink: Quote
freshfresh Posted October 1, 2009 Author Posted October 1, 2009 ok i am having a hard time using this not working as planed. Quote
Lee Mac Posted October 1, 2009 Posted October 1, 2009 ok i am having a hard time using this not working as planed. What part is not working? Quote
freshfresh Posted October 1, 2009 Author Posted October 1, 2009 I can get it to work on my station. Quote
alanjt Posted October 1, 2009 Posted October 1, 2009 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. Quote
Lee Mac Posted October 1, 2009 Posted October 1, 2009 I can get it to work on my station. So it works? If not, what error does it throw? Quote
freshfresh Posted October 1, 2009 Author Posted October 1, 2009 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 Quote
freshfresh Posted October 1, 2009 Author Posted October 1, 2009 i dont know how to make it work? Quote
alanjt Posted October 1, 2009 Posted October 1, 2009 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? Quote
alanjt Posted October 1, 2009 Posted October 1, 2009 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? Quote
freshfresh Posted October 1, 2009 Author Posted October 1, 2009 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? Quote
alanjt Posted October 1, 2009 Posted October 1, 2009 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. Quote
freshfresh Posted October 1, 2009 Author Posted October 1, 2009 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 Quote
alanjt Posted October 1, 2009 Posted October 1, 2009 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 Quote
alanjt Posted October 1, 2009 Posted October 1, 2009 Examples: (defun c:MJ (/) (and PlineDraw (PlineDraw "MAJOR" 3 0.02)) (princ)) (defun c:MN (/) (and PlineDraw (PlineDraw "MINOR" 2 0.01)) (princ)) Quote
alanjt Posted October 1, 2009 Posted October 1, 2009 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 " Quote
Recommended Posts
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.