Hello,
I need to be able to grab all polylines and change global width at once. This is a repetitve task that i have created a button for. I am trying to use this but it is not working. It gets hung up on me wanting to manually select the polylines when i thought i grabbed them with the first line.
(ssget "X" '((8 . "LayerName")))
(command "PEDIT" "w" "9")
Be careful to have your layer name is unlocked .
(Defun c:Test (/ ss) (if (setq ss (ssget "_x" '((0 . "*POLYLINE") (8 . "Layername")))) (command "_.pedit" "_m" ss "" "w" 9 "")) (princ))
@_Tharwat wrote:....
(Defun c:Test (/ ss) (if (setq ss (ssget "_x" '((0 . "*POLYLINE") (8 . "Layername")))) (command "_.pedit" "_m" ss "" "w" 9 "")) (princ))
If you ever use 3D Polylines, you'll need to make that more sophisticated. I find that with a selection of multiple Polylines, if any of them are 3D, the Width option is not offered, and the "w" will result in an invalid-option message, even if there are 2D and/or LW Polylines in the selection that width can be assigned to.
You are right Kent , 3dpolylines should be wxcluded from the selection set of the 2d polylines , so here it goes .
To OP , Don't forget to change the layer name to meet your needs .
(Defun c:Test (/ s ss sn i)
(if (setq s (ssadd)
ss (ssget "_x" '((0 . "*POLYLINE") (8 . "LayerName")))
)
(progn
(repeat (setq i (sslength ss))
(setq sn (ssname ss (setq i (1- i))))
(if (not (eq (cdr (assoc 100 (reverse (entget sn))))
"AcDb3dPolyline"
)
)
(ssadd sn s)
)
)
(if (> (sslength s) 0)
(command "_.pedit" "_m" s "" "w" 9 "")
)
(princ "\n .... ")
(princ (strcat "Number of Polylines changed : "
" < "
(itoa (sslength s))
" > "
)
)
)
(princ "\n Couldn't find any 2D polyline !!")
)
(princ)
)
@Kent1Cooper wrote:
....
If you ever use 3D Polylines, you'll need to make that more sophisticated. ... if any of them are 3D, the Width option is not offered, and the "w" will result in an invalid-option message....
Another way to go about it:
(foreach
x
(mapcar 'cadr ;; entity names in a list
(ssnamex (ssget "X" '((0 . "*POLYLINE") (8 . "YourLayerName"))))
)
(if (/= (substr (cdr (assoc 100 (reverse (entget x)))) 5 1) "3")
(vla-put-ConstantWidth (vlax-ename->vla-object x) YourWidth)
)
)
to which, of course, you can also add a report on how many it did, as _Tharwat did.
I actually tried that hoping that maybe you could not bother to check whether any were 3D -- that maybe it would just ignore those. But no, it gives an error if you try to "put" that property onto something that doesn't have it. You could check for (vlax-property-available-p) instead of the (assoc 100) approach, but I think it would take more code, including presumably storing of the vla-object conversion in a variable name, since you would need to use it twice as a vla object [to check whether it has that property, and if so, to put a value on it].
Hi,
you can use vl-catch-all-apply to ignore 3D polylines e.g.
(if (setq ss (ssget "X" '((0 . "*POLYLINE") (8 . "YourLayerName"))))
(foreach
x (mapcar 'cadr (ssnamex ss))
(vl-catch-all-apply
'vlax-put-property
(list (vlax-ename->vla-object x) 'ConstantWidth YourWidth)
)
)
)
Ian
A way to exclude 3dpolyline can be using this filter
(if (setq s (ssadd) ss (ssget "_x" '((0 . "*POLYLINE") (8 . "LayerName") ( 100 . "~AcDb3dPolyline" )) ) ~ (tilde) If it is the first character in the pattern, it matches anything except the pattern
can anybody please explain what is the meaning of these lines
(setq ss (ssget ":S:E" '((0 . "LWPOLYLINE") (-4 . "<>") (43 . 0))))
@rajeshkumar16484 wrote:
can anybody please explain what is the meaning of these lines
(setq ss (ssget ":S:E" '((0 . "LWPOLYLINE") ))
setq ss ; store selection set in variable ss
ssget ; get selection set
:S ; Allows single selection
:E ; within cursor's object selection pickbox
(0 . "LWPOLYLINE") ; of polyline (light pline)
(-4 . "<>") (43 . 0)) ; which has a constant width different than 0.
Can't find what you're looking for? Ask the community or share your knowledge.