Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ssget (Select diagonal line only )

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
boyds86
616 Views, 10 Replies

ssget (Select diagonal line only )

(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!

10 REPLIES 10
Message 2 of 11
Kent1Cooper
in reply to: boyds86

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?

Kent Cooper, AIA
Message 3 of 11
Sea-Haven
in reply to: boyds86

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.

Message 4 of 11
boyds86
in reply to: Kent1Cooper

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.

 

Chamfer.png

Message 5 of 11
Kent1Cooper
in reply to: boyds86


@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.

Kent Cooper, AIA
Message 6 of 11
devitg
in reply to: boyds86

@boyds86 

 

Would it always be the figure as shown , say large sides vertical or horizontal? 

and chamfer only 45 , 135 , 225 , 315 degree  , or 0.25 pi , 0.75 pi , 1.25 pi or 1.75 pi ?

If possible , upload a real dwg . 

 

 

 

 

Message 7 of 11
Kent1Cooper
in reply to: boyds86

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)))))

....

Kent Cooper, AIA
Message 8 of 11
Sea-Haven
in reply to: boyds86

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.

Message 9 of 11
boyds86
in reply to: Kent1Cooper

Thank you very much. This is the one I Need!

Message 10 of 11
boyds86
in reply to: devitg

Thank you for your concern! @Kent1Cooper has helped me!

Message 11 of 11
boyds86
in reply to: Sea-Haven

Thank you for your concern! It is solved by @Kent1Cooper 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report