Code Red > AutoLISP (Vanilla / Visual)

How to create donut by activeX

(1/2) > >>

Adesu:
I still got trouble to created a donut by activex,anyone know about it.

--- Code: ---(setq p1 '(0 0 0))
(setq p2 '(1 0 0))
(setq vgao (vlax-get-acad-object))
(setq vgad (vla-get-activedocument vgao))
(setq vgms (vla-get-modelspace vgad))
(setq object (vla-adddonut vgms (vlax-3d-point p1)(vlax-3d-point p2)))

--- End code ---

SomeCallMeDave:
Take a peek at the AddTorus method

Jeff_M:
Ade,
Create a donut in a drawing and list it. What kind of object is it? IOW, there is no "Donut" object. But, we can duplicate what Autodcad does:

--- Code: ---(defun c:mydonut()
  (my-adddonut
    (getdist "\nInside diameter: ")
    (getdist "....Outside Diameter: ")
    (getpoint "\nCenter point: ")
    )
  (princ)
  )

(defun my-adddonut (Rin Rout ctr / ctr end pline r start wid)
  (setq wid (- Rout Rin)
r (+ Rin wid))
  (setq start (polar ctr 0.0 r)
end (polar ctr pi r)
)
  (setq pline (vlax-invoke
(vla-get-modelspace
  (vla-get-activedocument
    (vlax-get-acad-object)
    )
  )
'addlightweightpolyline
(list (car start) (cadr start) (car end) (cadr end))
)
)
  (vla-setbulge pline 0 1.0)
  (vla-put-closed pline :vlax-true)
  (vla-setbulge pline 1 1.0)
  (vla-put-constantwidth pline wid)
  pline
  )

--- End code ---

Adesu:
Hi Jeff,
It's great thanks for your code.

Jeff_M:
You're welcome, Ade.

There's a slight problem with it, though, or with the test portion anyway. In it I ask for the Diameter's, yet I treat the responses as being the Radii. Make sure that what you pass the (my-adddonut) function the 2 radii, not diameters. :oops: Sorry about that.

Navigation

[0] Message Index

[#] Next page

Go to full version