Looking for a simple lisp routine to draw a polyline at a width of 3 and on a layer called wood, I would like to leave the command open to draw numerous ones until I end the routine
Why not perform the commands necessary yourself, copy them down and organize them into a program yourself?
(defun c:yourcommandname ( )
(command "put" "your" "string" "commands" "in" "quotes." "Include" "spaces" "or" "" for returns)
(princ)
)
When you've got that working, come back and get some help with cleanup to return layer to previous or to get help with looping.
Here this should get you where you need! Normally for something as simple as a PLINE, we would only use 'command' calls as dbroad is trying to infer, but in this case since you have a couple simple properties to change, and would like numerous lines, we need to keep track of a few more things.
(defun c:WPLINE ( / keepGoing lyr tmp) ;Wood PLINE (setq keepGoing t) (setq lyr (tblobjname "LAYER" "Wood")) (while keepGoing (command-s "_.PLINE" pause "w" 3.0 3.0) (if lyr (setpropertyvalue (entlast) "LayerId" lyr)) (initget "No Yes") (if (or (null (setq tmp (getkword "\nAnother? [No/Yes] <No>"))) (eq "No" tmp)) (setq keepGoing nil) (setq keepGoing t) );if );while (prompt "\nWPLINE Complete.") (princ) );defun
Best,
~DD
ok, that worked but I guess it actually slows me down to have it prompt for another one, could I just have the command end after drawing one line?
At that rate, then why not just use standard layer practices within AutoCAD? Your command would be merely be making a PLINE with 3 width on a specific layer. I know the little things can add up, so what is the slowest part of your workflow? ..Switching layers? ..Changing the PLINE width to 3?
Best,
~DD
@Ajohnson0 wrote:
.... could I just have the command end after drawing one line?
If you don't need to set current Layer and Polyline-width conditions back afterwards:
(defun C:YourCommandName ()
(setvar 'plinewid 3)
(setvar 'clayer "wood")
(command "_.pline")
(princ)
)
If you want to draw more than one, just whap the space bar to recall it.
[It presumes the "wood" Layer exists already, but it's an easy fix to make it work even if not.]
@Ajohnson0 wrote:
.... it actually slows me down to have it prompt for another one ....
Here's a version that just asks you to start another one right after you finish one, as many as you want, and the prompt needs a response from you only when you want to Exit. You can do that by either typing E [or any amount more of the word], or picking on that option in the prompt, or just hitting Enter or space to accept the offered <Exit> default. Lightly tested.
(defun C:YourCommandName (/ pt) (setvar 'plinewid 3) (setvar 'clayer "wood") (while (and (not (initget "Exit")); [(not) wrapper because always returns nil] (setq pt (getpoint "\nStarting point of next Pline or [Exit] <Exit>: ")) (listp pt); User picked a point ); and (command-s "_.pline" pt) ); while (princ) ); defun
It's not rocket science. BTW, most of what you want to do can be done by just making one of what you want and then dragging the polyline to a toolpalette. Then just click on the tool to place a polyline of a given thickness and on a specific layer.
BTW, Greek is worth learning too. That's what I'm doing now.
Learning Greek, eh?
Is that so you can figure out Pythagoras' theorem? 🙂
John F. Uhden
Try this:
(defun c:foo (/ _drawpolyline e) ;; RJP » 2020-01-22 (defun _drawpolyline (/ a) (setq a (entlast)) (vl-cmdf "_.pline") (while (> (getvar 'cmdactive) 0) (command "\\")) (if (not (equal a (entlast))) (entlast) ) ) (while (setq e (_drawpolyline)) (entmod (append (entget e) '((8 . "wood") (43 . 3))))) (princ) )
Could also do something like this to make it more versatile. Added a color option as well.
;; RJP » 2020-01-22 (defun _drawpolyline (l w c / a) (setq a (entlast)) (vl-cmdf "_.pline") (while (> (getvar 'cmdactive) 0) (command "\\")) (if (not (equal a (entlast))) (entmod (append (entget (entlast)) (list (cons 8 l) (cons 43 w) (cons 62 c)))) ) ) ;; Pline on 'wood' layer, width of 3 and color bylayer (defun c:wood nil (while (_drawpolyline "wood" 3 256)) (princ)) ;; Pline on 'woody' layer, width of 1 and color 44 (defun c:woody nil (while (_drawpolyline "woody" 1 44)) (princ)) ;; Pline on 'woodier' layer, width of 6 and color 88 (defun c:woodier nil (while (_drawpolyline "woodier" 6 88)) (princ))
Hey the winner its me, type P3 on command line and it will draw a pline 3 units wide type p4-5 and it will draw a pline 4.5 wide, this uses reactors to look at PXxxx, as it is reactor based the decimal dot is replaced by - as . is recognised in the command line. It does take a little bit to get used to type f3-5 but simple once you get the hang of it.
Now I have your attention I actually only have Offset, Circle and Fillet currently but no reason that pline could not be added. I have attached the reactor code for any one interested please repost with pline as need to find some time to add pline, For repeat method press spacebar, I need to look at P3 v's P3c which closes pline. P at moment does something else.
Almost forget "Lwood" as well need to add a layer current.
Can't find what you're looking for? Ask the community or share your knowledge.