Jump to content

Recommended Posts

Posted

I have a circle:

(setq circle (vlax-ename->vlax-objexct ....

A quick question: How can I find the diameter using *visual* lisp?

Posted
(setq ent (car(entsel)))
 (setq rad (* 2(vla-get-radius (vlax-ename->vla-object ent))))

; alternatively

(setq rad (* 2(cdr(assoc 40 (entget ent)))))

Either of these will get the diameter

Posted

Ah, so there is no diameter property for the circle! Thanks a lot.

I think you should change your code:

(setq DIAM (* 2 (.....

But it is ok, I got the sense.

The second way is auto lisp, not visual.

Thanks again.

Posted

I just found that (vla-get-Diameter circle) works too.

Ollie, I really appreciate your help.

Posted
I just found that (vla-get-Diameter circle) works too.

Ollie, I really appreciate your help.

 

np :)

 

I never even thought of trying vla-get-diameter

Posted

Yes, either:

 

(vla-get-diameter Obj)

 

Or

 

(vlax-get Obj 'Diameter)

 

Or

 

(vlax-get-property Obj 'Diameter)

 

 

You may want to check that the property exists first, using:

 

(if (vlax-property-available-p Obj 'Diameter)
...

 

Lee

Posted

Just as an aside, you probably know this, but you can check the properties and available methods for an Object using something like:

 

(defun c:dump  (/ ent obj)
 (setq ent (entsel "\nSelect entity to get object data: "))
 (print)
 (setq obj (vlax-ename->vla-object (car ent)))
 (vlax-dump-object obj t)
 (vlax-release-object obj)
 (textscr)
 (princ "\n")
 (princ))

Posted
Just as an aside, you probably know this...

Ha ha! I just start with Visual lisp!

before I asked for help, I tried (setq diam (vla-get-diameter circle)), but I missed something.

 

Is there a way to list the coords of the center point?

 

 

**** editing ****

 

I just found the vlax-safearray->list and probably it will do what I wish. I will try it tomorrow, here it is the time to go home now.

Posted

Nice one Fuccaro, I'm glad you are delving into the world of VL :D

 

For the Centre Point, there are a few ways that you can get at it.

 

A Circle has the center property and this can be retrieved using the following methods, each with varying returns:

 

Method 1:

 

(vla-get-Center <circle>)

 

Returns a Variant:

 

#<variant 8197 ...>

 

This can be converted to a SafeArray, then a 3D point using:

 

(vlax-safearray->list
 (vlax-variant-value
   (vla-get-center <circle>)))

 

Method 2:

(vlax-get-property <circle> 'Center)

 

This will also return a variant, and the above applies.

 

 

Method 3:

 

(vlax-get <circle> 'Center)

 

This is an older method, and the function vlax-get I don't think is documented. The method will return data in AutoLISP data types:

 

(-46.4701 16.7293 0.0)

 

If you have any further questions, just ask.

 

Lee

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