Selecting object in command dimdiameter (autolisp)

Selecting object in command dimdiameter (autolisp)

Anonymous
Not applicable
1,680 Views
1 Reply
Message 1 of 2

Selecting object in command dimdiameter (autolisp)

Anonymous
Not applicable

What i am trying to do is to set a dimension of the circle using autolisp.
Let's say I know a point on the circle - (x y). To set dimension I do:
(COMMAND "_DIMDIAMETER" ( LIST x y ) ( LIST (+ x 100) (+ y 100) ) "")
The problem is that if the point (x y) is out of vision (for example, I zoomed in to another area), the dimension won't be built.
How can I avoid such problem? Or can I select an object by the name (using entlast) instead of picking a point?
The same problem I have with picking points for a fillet using autolisp.
Also it's important that the pick point is not supposed to be set by the user during the process.

0 Likes
Accepted solutions (1)
1,681 Views
1 Reply
Reply (1)
Message 2 of 2

ВeekeeCZ
Consultant
Consultant
Accepted solution

Hi...

 

DIMDIAMETER not requires a circle being on visible part of the screen. But some functions (and commands) does (eg. ssget with points, see HERE), then you can use the ZOOM command: (command "_.ZOOM" "_Ob" (entlast) "")

But DIMDIAMETER requires an object name AND a point, combined by list: '(ename (10 10 0))

 

So your code could look like this... see the commentary... 

 

(defun c:AutoDimDia ( / circle pt-on-circle pt-for-dim)
  (if (and (setq circle (entlast))					; get the last object
           (= "CIRCLE" (cdr (assoc 0 (entget circle)))) 		; is it really a circle?
           (setq pt-on-circle (polar (cdr (assoc 10 (entget circle)))	; get circle's centre point
                                     (cdr (assoc 40 (entget circle))) 	; get circle's radius
                                     (* pi 0.5)))			; 45°
           (setq pt-for-dim (list (+ (car pt-on-circle) 100)
                                  (+ (cadr pt-on-circle) 100)
                                  0))
           )
    (command "_.DIMDIAMETER"
             (list circle       		; just object is not enough, some commands needs both ename and point, combined into list '(ename (10 10 0))
                   pt-on-circle)
             "_none" pt-for-dim) 		; don't forget turn off OSNAPS
  (princ)
)

HERE is a DXF definition of a circle - to know what blue code you need.