Jump to content

Recommended Posts

Posted
I know :wink:

 

But, how does one know what arc they want?

 

user supplies to points, if pt1 and pt2 are picked clockwise then one answer, otherwise another

 

(defun vk_GetLeftAngle (p1 p2 p3 / Ang)
 (if (minusp (setq Ang (rem (+ pi (angle p2 p1) (- (angle p3 p2))) (* pi 2.0))))
   (+ pi pi Ang)
   Ang
 )
)
(defun vk_GetArcLength (Ent pt1 pt2)
 (* (cdr (assoc 40 Ent)) (vk_GetLeftAngle pt1 (cdr (assoc 10 Ent)) pt2))
)

Posted

Been dissecting your code VovKa, and I must say, that is pure genius... where do you get your ideas from? :)

Posted
Been dissecting your code VovKa, and I must say, that is pure genius... where do you get your ideas from? :)

 

I steal them from math books :)

Posted
I steal them from math books :)

 

Now there was me thinking that you had thought them up yourself... :P

Posted
Oh, what command is missing in '02?

 

DIMARC - That why I did replace it with lisp

Posted

Ah ok, maybe this instead then:

 

(defun c:DimCir (/ doc spc ent p1 p2 ax cen)
 (vl-load-com)

 (setq doc (vla-get-ActiveDocument
             (vlax-get-Acad-Object))
       spc (if (zerop (vla-get-activespace doc))
             (if (= (vla-get-mspace doc) :vlax-true)
               (vla-get-modelspace doc)
               (vla-get-paperspace doc))
             (vla-get-modelspace doc)))

 (if (and (setq ent (car (entsel "\nSelect Circle: ")))
          (eq "CIRCLE" (cdr (assoc 0 (entget ent))))
          (setq p1 (getpoint "\nPt1: "))
          (setq p2 (getpoint "\nPt2: ")))
   (progn
     (setq ax
       (vla-addArc spc
         (vlax-3D-point
           (setq cen
             (cdr (assoc 10 (entget ent)))))
         (cdr (assoc 40 (entget ent)))
         (angle cen p1) (angle cen p2)))
     (vla-put-TextOverride
        (vlax-invoke spc 'adddimangular cen p1 p2 p1)
          (rtos
            (vla-get-ArcLength ax)))
     (vla-delete ax)
     (vl-cmdf "_.dimtedit" (entlast) pause)))

 (princ))

  • Like 1
Posted

I don't know how this happen but I am able to put dimension of longer arc on side of small arc as on picture ( red color)

Or this again issue of Acad version

ScreenShot010.jpg

Posted

It will depend upon which order the points are picked (i.e. counter/clockwise), but it is temperamental to say the least. :(

Posted

OK Lee, got it.

Thank you very much.

My next question... oops, need to start new topic (just kidding)

Thanks again.

Posted

here is my lisp i use it and tested and can write the length of three consequent points

(defun c:leng ()
(command"regen""")
(setq clyr(getvar"clayer"))
(while
(setq m1 (getpoint "\n please click on first point of curve"))
(setq osmd(getvar"osmode"))

(setq m2 (getpoint "\n click second point on circle"))
(setq m3 (getpoint "\n click third point of curve"))

(setq g (/(+(car m1)(car m2))2)
h (/(+(cadr m1)(cadr m2))2)
i (/(+(car m1)(car m3))2)
j (/(+(cadr m1)(cadr m3))2)
m (-(car m2)(car m1))
n (-(cadr m2)(cadr m1))
o (-(car m3)(car m1))
p (-(cadr m3)(cadr m1))
y0 (/(-(-(+(*(* o m)i)(*(* p m)j))(*(* o g)m))(*(* o n)h))(-(* m p)(* o n)))
x0 (/(+(-(* g m)(* n y0))(* n h))m)
r0 (sqrt(+(expt(- x0 (car m1))2)(expt(- y0 (cadr m1))2)))
ccm (list x0 y0)
a1 (angle ccm m1)
a2 (angle ccm m2)
a3 (angle ccm m3)
a2x (sin a2)
a2c (cos a2)
a2m (/ a2x a2c)
)
(cond
((and(< a1 a2)(< a1 a3)(< a2 a3))
(setq ang0 (- a3 a1)))
((and(> a1 a2)(> a1 a3)(> a2 a3))
(setq ang0 (- a1 a3)))
((and(> a1 a2)(> a1 a3)(< a2 a3))
(setq ang0 (-(* 2 pi)(- a1 a3))))
((and(< a1 a2)(> a1 a3)(> a2 a3))
(setq ang0 (-(* 2 pi)(- a1 a3))))
((and(< a1 a2)(< a1 a3)(> a2 a3))
(setq ang0 (-(* 2 pi)(- a3 a1)))) 
((and(> a1 a2)(< a1 a3)(< a2 a3))
(setq ang0 (-(* 2 pi)(- a3 a1))))
)
(setq l0 (* r0 ang0))
(setq a2g (/(* a2 200)pi))
(setq az2 (atan 1 a2m))
(setq az2g (/(* az2 200)pi))
(setq m21(polar m2(+ a2(* 2 pi)) 0.4)) 
(command "color"1)

(command "color"6)
(setvar"osmode"0) 
(command "text" m21"1"az2g(rtos l0 2 3))
(setvar "osmode"osmd)
)
)

;be sure texthight is zero

  • Like 1
Posted

I am off my computer, will back on Monday. Have a good weekend everybody!!!

  • 14 years later...
Posted (edited)

hello everyone
Very convenient lisp (DimCir.lsp), help to improve it a little...
How to add ORTHO mode shutdown to lisp correctly when calling the command,
if ORTHO mode is enabled, the dimensions are obtained incorrectly...
thanks...

(defun c:DimCir (/ doc spc ent p1 p2 ax cen)
 (vl-load-com)

 (setq doc (vla-get-ActiveDocument
 (vlax-get-Acad-Object))
 spc (if (zerop (vla-get-activespace doc))
 (if (= (vla-get-mspace doc) :vlax-true)
 (vla-get-modelspace doc)
 (vla-get-paperspace doc))
 (vla-get-modelspace doc)))

 (if (and (setq ent (car (entsel "\nSelect Circle: ")))
 (eq "CIRCLE" (cdr (assoc 0 (entget ent))))
 (setq p1 (getpoint "\nPt1: "))
 (setq p2 (getpoint "\nPt2: ")))
 (progn
 (setq ax
 (vla-addArc spc
 (vlax-3D-point
 (setq cen
 (cdr (assoc 10 (entget ent)))))
 (cdr (assoc 40 (entget ent)))
 (angle cen p1) (angle cen p2)))
 (vla-put-TextOverride
 (vlax-invoke spc 'adddimangular cen p1 p2 p1)
 (rtos
 (vla-get-ArcLength ax)))
 (vla-delete ax)
 (vl-cmdf "_.dimtedit" (entlast) pause)))

 (princ))

 

Edited by Nikon
Posted (edited)

I add (setvar "orthomode" 0) ; off, I select the points clockwise,
but the dimensions are still set either correctly or incorrectly...

 

Image 3.png

Edited by Nikon

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...