View Full Version : Polyline Width
robert.1.hall72202
2004-09-24, 01:03 PM
Do not laugh at me, Im trying to learn lisp.
I wish to make a routine that executes the Pedit/Width command.
Only 2 options I select are Join and Width so it would be nice
to go straight to the command. I don't think I am looking at lisp
routines correctly because this is what I have and it doesn't work.
(defun c:Pw ()
(command ".pedit" pause "" '(width) )
(PRINC)
)
Can somebody set me straight???
It pauses for selection but I cannot recognize the width??
bcowper
2004-09-24, 02:31 PM
No one should laugh we all have to start somewhere, I am by no means an expert on lisp but this is what I came up with for the pedit width command:
(defun c:Pw (/ ss1 plwidth)
(setq ss1 (ssget :s)
plwidth (getreal "Polyline Width: ")
)
(command ".pedit" ss1 "w" plwidth "")
(PRINC)
)
The key here is to select your object (polyline) first and then the width you want and then pass these to the pedit command. Try changing my code around to come up with a routine for using the join command.
This is old fashioned lisp and if I had the time I could create visual lisp program that is much more effective and error free than this, but I'm happy using the standard pedit and mpedit commands.
bcowper
2004-09-24, 02:37 PM
I should also explain what I added/amended to your program:
(defun c:Pw (/ ss1 plwidth)
- declares what variables are used in program
(setq ss1 (ssget :s)
- create a selection set: pedit only accepts one polyline
plwidth (getreal "Polyline Width: ")
) - ask user for polyline width at command line
(command ".pedit" ss1 "w" plwidth "")
(PRINC)
) - pass selection set and Polyline width to PEdit command.
Hope this helps.
CAB2k
2004-09-25, 02:13 PM
Here is some code for you to ponder.
; This version uses ssget ":S" which can select more that one
; pline if you use the crossing window method of selecting
; if more than one is selected only the first will be changed
(defun c:pw (/ ss plwidth); (passes vars / local vars)
(prompt "\nSelect the Polyline to change Width.")
(and ; all that follow must be true, else quit the AND
;; get single selection of only polylines
(setq ss (ssget ":S" '((0 . "*POLYLINE"))))
;; test for empty selection sets
(> (sslength ss) 0)
;; prevent ENTER, neg numbers
(null (initget (+ 1 4))) ; null (initget) returns true
;; get the width needed
(setq plwidth (getreal "\n*-* Enter Polyline Width: "))
(command ".pedit" ss "w" plwidth "")
); end and
(princ)
)
(prompt "\nPolyline Width Command Loaded, Enter PW to run.")
(princ)
;; Another option is to use entsel, it allows one pick but
;; has no object filter, you must take care of that
(defun c:pw2 (/ ss plwidth) ; (passes vars / local vars)
(setq loop t)
(while loop
(if (setq ent (entsel "\nSelect the Polyline to change Width."))
;; got something
(cond
((and (setq elst (entget (car ent)))
(vl-string-search "POLYLINE" (cdr (assoc 0 elst)))
)
;; got a poly line
(initget (+ 1 4)) ; prevent ENTER, neg numbers
(setq plwidth (getreal "\n*-* Enter Polyline Width: "))
(command ".pedit" (car ent) "w" plwidth "")
(setq loop nil) ; exit loop
)
((prompt "\n*-* Not a poyline, try again. *-*."))
)
)
) ; while
(princ)
)
(prompt "\nPolyline Width Command Loaded, Enter PW to run.")
(princ)
RobertB
2004-09-25, 03:14 PM
(setq ss (ssget ":S" '((0 . "*POLYLINE"))))
I should mention that, although that filter will catch all variations of the standard polylines, it will also select any custom objects that match that name also, which may not work like normal plines.
Therefore, a better filter would be: (setq ss (ssget ":S" '((0 . "POLYLINE,LWPOLYLINE"))))
CAB2k
2004-09-26, 01:04 AM
Thanks for the 'Heads Up' Robert.
What are the names of the other ployline entities?
My experience has been limited to the common objects.
peter
2004-09-26, 03:50 PM
Maybe this would work for you
Peter Jamtgaard
(defun C:setwid (/ intCount entSelection objSelection sngWidth ssSelections
)
(setq ssSelections (ssget (list (cons 0 "lwpolyline,polyline")))
sngWidth (getdist "\nEnter polyline width: ")
)
(if ssSelections
(repeat (setq intCount (sslength ssSelections))
(setq intCount (1- intCount)
entSelection (ssname ssSelections intCOunt)
objSelection (vlax-ename->vla-object entSelection)
)
(repeat (setq intParam (fix (vlax-curve-getendparam objSelection)))
(setq intParam (1- intParam))
(vla-setwidth objSelection intParam sngWidth sngWidth)
)
)
)
(princ)
)
anssi.wainio
2004-09-27, 07:45 PM
I may be deviating from the subject, but in the golden days before the lwpolyline object was invented, it was possible to write a lisp program to set the width of single polyline vertices by clicking on them. I have not found a way to do the same with lwpolylines. Is it possible?
Anssi
Jeff_M
2004-09-28, 07:31 AM
To set the width at individual vertice you can:
Use the properties dialog,
Use activeX and the SetWidth method,
use entmod on the individual assoc 40 & 41's for each vertex..........
So to answer your question, Yes, it's possible.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.