PDA

View Full Version : Visual Lisp - Questions on vla- and vlax- command prefixes


sivampeta_dheeraj
2008-07-29, 06:58 PM
In Vlisp commands begin with either vlax or vla.Is there any theoretical synopsis which can help one in differentiating one from the other? To put it simply how can we remember to prefix vlax to, for example vlax-ename->vla-object and vla to vla-get-layer.

To further simplify where and how vlax and vla have to be used and why.

T.Willey
2008-07-29, 07:16 PM
Some can be written more than one way, and some have to be written only one way. In your example, vla-get-layer, it can be written at least three ways, and they all return the same thing, but with experience you will notice that doing it one way will give you want you want in some instances.

Example

vla-get-Layer
vlax-get obj 'Layer
vlax-get-property obj 'Layer

all return a string that is the layer name.

If you have a block ( or anything that returns a point/vector ) and you are using lisp, then you might want to try it a different way, as you will get better results

Example

vla-get-InsertionPoint -> variant
vlax-get obj 'InsertionPoint -> list


So to answer your question, not really, and it doesn't really matter. Experience will help you the most and experiment.

Hope that helps.

sivampeta_dheeraj
2008-07-29, 07:24 PM
Thanks for your reply.Just feel I am beginning to get hold of the thing.Your answer has helped me a good deal in this regard.

T.Willey
2008-07-29, 08:45 PM
Thanks for your reply.Just feel I am beginning to get hold of the thing.Your answer has helped me a good deal in this regard.

You're welcome, and it is good to hear. Good luck in learning the VLisp, or ActiveX, part of the Lisp language.

irneb
2008-07-30, 06:21 AM
The vlax functions are the basis of the Visual Lisp extensions. The vla functions are "shortcut" functions created from the ActiveX properties and methods.

So (assuming obj is an Object reference) then the following are equivalent:
(vlax-get-Property obj 'Layer) ;| same as |; (vla-get-Layer obj)
(vlax-put-Property obj 'Layer "0") ;| same as |; (vla-put-Layer obj "0")
(vlax-invoke-method obj 'Copy) ;| same as |; (vla-Copy obj)

patrick35
2008-07-30, 07:58 AM
Hi

(vlax-get-Property obj 'Layer) ;| same as |; (vla-get-Layer obj)
(vlax-put-Property obj 'Layer "0") ;| same as |; (vla-put-Layer obj "0")
(vlax-invoke-method obj 'Copy) ;| same as |; (vla-Copy obj)

I am not quite agree

For example

(vlax-invoke (vla-get-plot (vla-get-activedocument (vlax-get-acad-object))) 'plottodevice)
vs
(vla-plottodevice (vla-get-plot (vla-get-activedocument (vlax-get-acad-object))))
We do not have the same result as with the first instruction, we see the progress bar plotter but not with the second

Another example
(setq ent (vlax-ename->vla-object (car (entsel))))
A (vla-get-insertionpoint ent) return #<variant 8197 ...>
A (vlax-get ent 'insertionpoint) return (11452.9 8565.71 -3.37079e-049)

@+

irneb
2008-07-30, 09:33 AM
I am not quite agreeSorry, I should have been more clear. It should be similar to instead of same as. In most cases they're exactly the same, but as per your examples there are some instances with variations in how they work / what they return. The basic functionality is still the same though.

ttaahhhh
2008-07-31, 12:59 AM
Hi



I am not quite agree

For example

(vlax-invoke (vla-get-plot (vla-get-activedocument (vlax-get-acad-object))) 'plottodevice)
vs
(vla-plottodevice (vla-get-plot (vla-get-activedocument (vlax-get-acad-object))))
We do not have the same result as with the first instruction, we see the progress bar plotter but not with the second

Another example
(setq ent (vlax-ename->vla-object (car (entsel))))
A (vla-get-insertionpoint ent) return #<variant 8197 ...>
A (vlax-get ent 'insertionpoint) return (11452.9 8565.71 -3.37079e-049)

@+

vlax-invoke is not equal vlax-invoke-method

patrick35
2008-07-31, 07:28 AM
Ah thank you
And what is the difference between the two?

@+

'gile'
2008-07-31, 10:58 AM
vlax-invoke is not equal vlax-invoke-method

Ah thank you
And what is the difference between the two?

The difference between vlax-invoke, on one side and vlax-invoke-method or vla on the other side is mainly the same as between vlax-put and vlax-put-property or vla.
The data type requiered and return may be a list with vlax-invoke, a variant or a safarray otherwise.

Example

(setq mspace (vla-get-ModelSpace
(vla-get-ActiveDocument (vlax-get-acad-object))
)
obj (vlax-ename->vla-object
(car (entsel "\vSelect a closed pline: "))
)
array (vlax-safearray-fill
(vlax-make-safearray vlax-vbObject '(0 . 0))
(list obj)
)
)


(vlax-invoke mspace 'addRegion (list obj))
;; requieres a list of objects
;; returns a list : (#<VLA-OBJECT IAcadRegion 077c80f4>)

(vlax-invoke-method mspace 'addRegion array)
;; requieres an array of objects
;; returns a variant (array of objects) : #<variant 8201 ...>

(vla-addRegion mspace array)
;; requieres an array of objects
;; returns a variant (array of objects) : #<variant 8201 ...>

patrick35
2008-07-31, 11:13 AM
Thanks 'gile'

I had never noticed this subtlety.

@+

irneb
2008-07-31, 12:47 PM
The problem I have with vlax-invoke / put / get is they're not handled in help. So you don't have a description of exactly what they need as arguments or what they return. Thus they're actually some undocumented functions. If what you're saying about return values as lists instead of variants / arrays is true in all cases - they're probably a good thing to use since it could save you some programming.

At least with vlax-invoke-method / get-property / put-property they work as described in help. As do the vla versions - although you always have to look at at least 2 pages in help to find out. The counter to this is you usually have to convert those variants / arrays to usable lisp data types when mixing between the DXF code (ent....) functions and the vla / vlax.