(defun c:CV ()
(setvar "cmdecho" 0)
(command "undo" "be")
(setq osm (getvar "osmode"))
(setvar "regenmode" 1)
(setvar "osmode" 0)
(if(setq A (ssget "_:L" '((0 . "LINE"))))
(progn
(setq n 0)
(setq B (sslength A))
(while (< n B)
(setq C(ssname A n))
(setq D(entget C))
(setq E(cdr(assoc 10 D)))
(command ".QDIM" C "" E "")
(setq n (+ n 1)))))
(setvar "cmdecho" 1)
(setvar "osmode" osm)
(command "undo" "end")
(princ))
----------------
I am trying to create a lisp that call out the chamfer dimension. But I do not know how to choose diagonal line (45°) only (Not Vertical line & Horizontal line). I get stuck in here-->(if(setq A (ssget "_:L" '((0 . "LINE") (choose diagonal line condition))))
Thank you for your time!
Solved! Go to Solution.
Solved by Kent1Cooper. Go to Solution.
Solved by Kent1Cooper. Go to Solution.
You can't filter for the angle of Lines in (ssget), since it is not something that is stored in their entity data -- it is only a result from what is stored [the endpoints].
You would need to select Lines, and have their angles checked, keeping those at the angle(s) you want and removing others from the selection. Since Chamfer doesn't need to have equal setbacks on both sides, it can make corner Lines across orthogonal originals that are not at 45°. If you really mean those at 45° [in any of the 4 directions] only, resulting from equal-setback Chamfers on orthogonal original Lines, the method would be to check that the absolute value of the difference in X coordinates from the start to the end is the same as the difference in Y coordinates [within some tolerance].
Do you ever use unequal-setback Chamfers? It would be easy enough to find all Lines among a selection that are not orthogonal, that is, in which neither the X or Y difference between ends is zero, but would that get what you want?
Do you want Chamfered-corner Lines between Lines that are not orthogonal? Those would be very difficult, if even possible, for a routine to identify. What about between original Lines that are not perpendicular to each other?
Like Kent if you have a pline with the chamfer as part of the pline you can pick it and get segment and the 2 vertice points, like wise though could walk through a pline looking at segment angle.
If happy to do pick, pick,pick can look at line or pline and do dimension.
It is not necessary to use the ssget, I want to choose all the diagonal lines (Exactly 45° ) for one time by choose an area i want to dimension. Then I use Qdim to dimension them.
@boyds86 wrote:
.... I want to choose all the diagonal lines (Exactly 45° ) ....
One way you can try:
....
(setq D (entget C))
(setq
E (cdr (assoc 10 D))
F (cdr (assoc 11 D))
delta (mapcar '- F E); difference start to end
); setq
(if (equal (abs (car delta)) (abs (cadr delta)) 0.01); at some 45° direction in XY
(command ".QDIM" C "" E ""); then
); if
(setq n (+ n 1)))))
....
You can adjust the 0.01 fuzz factor for how exactly at 45° a Line is, if needed.
An angle-based [rather than XY-difference-based] approach:
....
(setq D (entget C))
(setq
E (cdr (assoc 10 D))
F (cdr (assoc 11 D))
); setq
(if (equal (rem (angle E F) (/ pi 2)) (/ pi 4) 0.001); at some 45° direction
(command ".QDIM" C "" E ""); then
); if
(setq n (+ n 1)))))
....
The other way maybe for unequal length chamfer but still dim them and may work rotated as well would be get bounding box use a length factor less than 25% of min ht wid, A real dwg would be good are they lines easy plines a bit harder.
Can't find what you're looking for? Ask the community or share your knowledge.