Author Topic: How to create donut by activeX  (Read 1958 times)

0 Members and 1 Guest are viewing this topic.

Adesu

  • Guest
How to create donut by activeX
« on: January 07, 2008, 08:54:58 PM »
I still got trouble to created a donut by activex,anyone know about it.
Code: [Select]
(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)))

SomeCallMeDave

  • Guest
Re: How to create donut by activeX
« Reply #1 on: January 07, 2008, 09:07:32 PM »
Take a peek at the AddTorus method

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: How to create donut by activeX
« Reply #2 on: January 07, 2008, 09:47:35 PM »
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: [Select]
(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
  )

Adesu

  • Guest
Re: How to create donut by activeX
« Reply #3 on: January 07, 2008, 11:31:08 PM »
Hi Jeff,
It's great thanks for your code.

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: How to create donut by activeX
« Reply #4 on: January 08, 2008, 01:22:33 AM »
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.

Adesu

  • Guest
Re: How to create donut by activeX
« Reply #5 on: January 08, 2008, 01:44:19 AM »
Hi Jeff,
After I analysis your code, I still confuse that your code not direct create a donut, but you create as like maneuvering.
Code: [Select]
(setq rin 0)
(setq rout 5)
(setq ctr '(0 0 0))
(setq wid (- rout rin))
(setq r (+ rin wid))
(setq start (polar ctr 0.0 r))
(setq end (polar ctr pi r))
(setq vgao (vlax-get-acad-object))
(setq vgad (vla-get-activedocument vgao))
(setq vgms (vla-get-modelspace vgad))
(setq object (vlax-invoke vgms 'addlightweightpolyline
      (list (car start) (cadr start) (car end) (cadr end)))) ; create a line
(vla-setbulge object 0 1.0)          ; convert line to arc
(vla-put-closed object :vlax-true)   ; connect start and end arc by line
(vla-setbulge object 1 1.0)          ; convert to a circle
(vla-put-constantwidth object wid)   ; already to donut