Author Topic: Trick question  (Read 5978 times)

0 Members and 1 Guest are viewing this topic.

SMadsen

  • Guest
Trick question
« on: January 19, 2004, 12:09:25 PM »
First one to answer wins .. umm .. nothing:

From the programmers point of view, what is the main difference between
VLAX-INVOKE and VLAX-INVOKE-METHOD,
VLAX-GET and VLAX-GET-PROPERTY,
and VLAX-PUT and VLAX-PUT-PROPERTY ?

JohnK

  • Administrator
  • Seagull
  • Posts: 10626
Trick question
« Reply #1 on: January 19, 2004, 12:13:16 PM »
Ooo, thats a good question.

One has to do with "TO an object" and the other is "WITH  an object."
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Re: Trick question
« Reply #2 on: January 19, 2004, 12:23:55 PM »
Quote from: SMadsen
First one to answer wins .. umm .. nothing:

From the programmers point of view, what is the main difference between
VLAX-INVOKE and VLAX-INVOKE-METHOD,
VLAX-GET and VLAX-GET-PROPERTY,
and VLAX-PUT and VLAX-PUT-PROPERTY ?


VLAX-INVOKE, VLAX-GET and VLAX-PUT are the old method.
TheSwamp.org  (serving the CAD community since 2003)

Columbia

  • Guest
Trick question
« Reply #3 on: January 19, 2004, 12:29:19 PM »
Well, depending on the type of programmer there could be a couple of different views on the answer to this question.

I believe Mark is right when he says that the shortened version is the "old method," but that doesn't necessarily mean that's the biggest difference.

One could say that vlax-invoke, vlax-get, and vlax-put, don't always work with the newer AutoCAD Active-X exposed objects like TrueColor.  But maybe that's not the biggest difference either...

I think, and this is just opinion now, that the biggest difference to a programmer ( a lazy person, by definition, because he/she is getting a machine to his/her work) is that vlax-invoke-method, vlax-put-property, & vlax-get-property are more self documenting than the others.  When going back and rereading the code, you can tell what is a method and what is a property because it out and out says it in the function.

That's just my two cents worth... :)

SMadsen

  • Guest
Trick question
« Reply #4 on: January 19, 2004, 01:42:50 PM »
The short versions are earlier versions of the longer versions - correct - but as a programmer I would only be interested in what the functions do, not when they were written.

Try create a random line:

(setq aLine (vla-addline (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))) (vlax-3D-point '(0.0 0.0 0.0))(vlax-3D-point '(100.0 100.0 0.0))))

Now try VLAX-GET-PROPERTY to, say, get the start point:

(vlax-get-property aLine 'startPoint)
#<variant 8197 ...>

.. and VLAX-GET:

(vlax-get aLine 'startPoint)
(0.0 0.0 0.0)

Anyone see the difference?

SMadsen

  • Guest
Trick question
« Reply #5 on: January 19, 2004, 01:46:38 PM »
Quote from: Columbia
One could say that vlax-invoke, vlax-get, and vlax-put, don't always work with the newer AutoCAD Active-X exposed objects like TrueColor.

You came very close :)

JohnK

  • Administrator
  • Seagull
  • Posts: 10626
Trick question
« Reply #6 on: January 19, 2004, 02:00:19 PM »
The "older versions" take longer then the new versions because they are pulling the data out of the variant. (therfore going thru a couple of more procedures.)

With the "stuff" still wraped in a variant, does that mean the variable is bigger? Does that mean that any "object" can view that data?
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

JohnK

  • Administrator
  • Seagull
  • Posts: 10626
Trick question
« Reply #7 on: January 19, 2004, 02:03:14 PM »
Oh i think i see something.  ....BRB
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Trick question
« Reply #8 on: January 19, 2004, 02:03:57 PM »
Cool ... I'll have to remember that....
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

SMadsen

  • Guest
Trick question
« Reply #9 on: January 19, 2004, 02:58:40 PM »
Quote from: Se7en
The "older versions" take longer then the new versions because they are pulling the data out of the variant. (therfore going thru a couple of more procedures.)

With the "stuff" still wraped in a variant, does that mean the variable is bigger? Does that mean that any "object" can view that data?

I have no idea what amount of memory variants use (a guess would be a long for pointer, an integer for type and whatever bytes in the heap to store the type of variant value). I don't know if it's slower, either, but I think Columbia points out the main thing when he says that the older methods do not work on some types of data (e.g. there is no variant definition in AutoLISP for OLE Color's).

Matt Stachoni

  • Guest
Trick question
« Reply #10 on: January 28, 2004, 07:38:21 PM »
My guess is that the (vlax-get) has been superceded by (vlax-get-property), probably because Autodesk wanted to enforce proper OO code design onto users.

Because objects expose methods and properties as part of their definition, the (vlax-get) function had to be written to accomodate all methods and properties. And, as it was pointed out, it also returns the value in more "normal" terms instead of as variants, which also takes time.

I thought this was interesting:

Command: (vlax-get aline 'Mirror) ;<- Mirror is a method
; error: Member not found

Command: (vlax-get aline 'Nothing) ;; dummy property
; error: ActiveX Server returned the error: unknown name: "NOTHING"

Command: (vlax-get-property aline 'Mirror)
; error: ActiveX Server returned an error: Type mismatch

Command: (vlax-get-property aline 'Nothing)
; error: ActiveX Server returned the error: unknown name: NOTHING

That says that maybe (vlax-get) has to first gather all of the exposed ActiveX names (properties and methods) into a list, then test them to see if the argument exists in that list, then see if that is a property (not a method), then gather the data, then format it into a list. That's a lot of overhead. Maybe the functions were just too clumsy and inelegant.

I think Autodesk wanted to make sure everyone was properly dealing with Variants in their own terms, instead of trying to second guess that we'd all want a LIST data type trying to gather the 'StartPoint property. In VLisp, yeah, probably 99% of the time we would, but if we were passing that value to VBA, we'd want the variant.

Knowing what I know about other programming languages, I would guess that in AutoCAD any and all variants takes up exactly the same amount of memory space - 16 bytes. In other languages (c/c++/Pascal), the first two bytes contain a number (a short integer) that tells how to interpret the other 14 bytes. If the indication is that the other 14 btes do not correspond to a "primitive" type (Boolean, byte, INT, long, float or double), it's a pointer to a more complex structure.

Or something.

SMadsen

  • Guest
Trick question
« Reply #11 on: January 29, 2004, 06:43:43 AM »
Thanks for the info, Matt.

There's no doubt that the older VLA-GET et al. goes out of its way to get what is asked of it.

Why don't you join as a member? If you hurry you can be member #100

JohnK

  • Administrator
  • Seagull
  • Posts: 10626
Trick question
« Reply #12 on: January 29, 2004, 11:04:05 AM »
huh? Now you got me thinking again.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org