TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: ImaJayhawk on August 30, 2004, 04:49:24 PM

Title: Vlax-get-property
Post by: ImaJayhawk on August 30, 2004, 04:49:24 PM
I'm tryinng to get the size of ductwork by lisp.  So I

Code: [Select]

(setq e (car (entsel)))
(setq vlaobj (vlax-ename->vla-object e))
(vlax-get-property vlaobj '??????)


Is there any way to get a list of the parameters for this object other than trial and error?
Thanks.

--ImaJayhawk
ABS 3.3
Title: Vlax-get-property
Post by: Mark on August 30, 2004, 04:58:51 PM
Take a look at vlax-dump-object
Title: Vlax-get-property
Post by: MP on August 30, 2004, 05:11:05 PM
Mark's right, vlax-dump-object (see the help) is invaluable.

At the risk of being self serving, if you're used to dxf codes this tool (http://www.theswamp.org/lilly.pond/puckett/lisp/info.zip)[/b] might be useful, it shows you the vlax-dump-object info, as well as the dxf codes, making it easy to compare the two representations of the data:

Code: [Select]
; IAcadPoint: AutoCAD Point Interface
; Property values:
;   Application (RO) = #<VLA-OBJECT IAcadApplication 00af9594>
;   Coordinates = (22.5004 7.7156 0.0)
;   Document (RO) = #<VLA-OBJECT IAcadDocument 01038600>
;   Handle (RO) = "89"
;   HasExtensionDictionary (RO) = 0
;   Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 03090e54>
;   Layer = "0"
;   Linetype = "ByLayer"
;   LinetypeScale = 1.0
;   Lineweight = -1
;   Normal = (0.0 0.0 1.0)
;   ObjectID (RO) = 2130005640
;   ObjectName (RO) = "AcDbPoint"
;   OwnerID (RO) = 2130005240
;   PlotStyleName = "ByLayer"
;   Thickness = 0.0
;   TrueColor = #<VLA-OBJECT IAcadAcCmColor 03093bd0>
;   Visible = -1
; Methods supported:
;   ArrayPolar (3)
;   ArrayRectangular (6)
;   Copy ()
;   Delete ()
;   GetBoundingBox (2)
;   GetExtensionDictionary ()
;   GetXData (3)
;   Highlight (1)
;   IntersectWith (2)
;   Mirror (2)
;   Mirror3D (3)
;   Move (2)
;   Rotate (2)
;   Rotate3D (3)
;   ScaleEntity (2)
;   SetXData (2)
;   TransformBy (1)
;   Update ()
; DXF Group Codes:
;   (-1 . <Entity name: 7ef54e88>)
;   (0 . "POINT")
;   (330 . <Entity name: 7ef54cf8>)
;   (5 . "89")
;   (100 . "AcDbEntity")
;   (67 . 0)
;   (410 . "Model")
;   (8 . "0")
;   (100 . "AcDbPoint")
;   (10 22.5004 7.7156 0.0)
;   (210 0.0 0.0 1.0)
;   (50 . 0.0)

Cheers.
Title: Vlax-get-property
Post by: ImaJayhawk on August 30, 2004, 05:24:13 PM
Thanks that's what I needed.


--ImaJayhawk
Title: Vlax-get-property
Post by: daron on August 31, 2004, 08:28:30 AM
Remeber, you could also use (vla-get-propertyname vla-object) as well. Same with (vla-put-propertyname vla-object value)
Title: Vlax-get-property
Post by: ImaJayhawk on August 31, 2004, 08:55:22 AM
What's the advantage in using (vla-get-propertyname vla-object) ?


--ImaJayhawk
Title: Vlax-get-property
Post by: daron on August 31, 2004, 08:59:41 AM
Shorter? Probably nothing, just an easier way to read it, because you know the property name right away. It doesn't matter, either way. I was just throwing out another way to skin that cat.
Title: Vlax-get-property
Post by: sinc on August 31, 2004, 09:06:53 PM
The (vla-get-propertyName vla-object) form is a binding that is resolved during compilation, while the (vlax-get-property vlaobj 'propertyName) form is a binding that is resolved at runtime.  The first version runs faster, but the difference in speed is frequently not noticeable.

The first form requires you to register a type library describing the ActiveX interface for your target object model with the VLisp environment before you can use it.  The default Autocad object model is registered automatically.  If you use vertical products (such as Land Desktop, etc.) or want to communicate with any external programs (such as Excel), you need to register the type library for that particular program explicitly as detailed here (http://theswamp.org/phpBB2/viewtopic.php?p=24896#24896).
This form has the advantages that it runs faster, it requires less typing, syntax-highlighting will work, and you will get a compiler error if you attempt to access an invalid property.

If you don't have the type library, or don't want to load it for some reason, you can use the second form (the vlax-get-property vlaobj 'propertyName one).  The reference to the property will then be resolved while the program is running, which slows execution.  Also, if you misspell a property name or try to access an invalid property, your code will compile fine, but you'll get a runtime error.
Title: Vlax-get-property
Post by: SMadsen on September 01, 2004, 04:49:13 AM
Very good info and nicely explained. Thanks, Richard.