fuccaro Posted July 30, 2009 Posted July 30, 2009 I have a circle: (setq circle (vlax-ename->vlax-objexct .... A quick question: How can I find the diameter using *visual* lisp? Quote
ollie Posted July 30, 2009 Posted July 30, 2009 (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 Quote
fuccaro Posted July 30, 2009 Author Posted July 30, 2009 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. Quote
fuccaro Posted July 30, 2009 Author Posted July 30, 2009 I just found that (vla-get-Diameter circle) works too. Ollie, I really appreciate your help. Quote
ollie Posted July 30, 2009 Posted July 30, 2009 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 Quote
Lee Mac Posted July 30, 2009 Posted July 30, 2009 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 Quote
Lee Mac Posted July 30, 2009 Posted July 30, 2009 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)) Quote
fuccaro Posted July 30, 2009 Author Posted July 30, 2009 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. Quote
Lee Mac Posted July 30, 2009 Posted July 30, 2009 Nice one Fuccaro, I'm glad you are delving into the world of VL 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 Quote
Recommended Posts
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.