Author Topic: Exposing Objects in VLISP  (Read 6124 times)

0 Members and 1 Guest are viewing this topic.

ML

  • Guest
Exposing Objects in VLISP
« on: March 17, 2008, 05:08:51 PM »
Hi
I was asked if I can expose the objects from Land Desktop in VLISP.
I know that in VBA, I can connect to the type library: AutoDesk Land 4.0 Type Library
then all of the objects are exposed in the VBAIDE

From what I read, I only need to path to The type (tlb) library in VLISP
 
Code: [Select]
(vlax-import-type-library
    :tlb-filename "C:\Program Files\Autodesk Land Desktop 2006\LandAuto46.tlb"
    :methods-prefix ""
    :properties-prefix ""
    :constants-prefix ""
Now, I have never really used VLISP before, so I believe I have made the connection but I am not sure how to get to the Land Desktop objects.

Any suggestions?
Also, is there a way to run code in VLISP with apploading it with each change?

Thank you,
Mark

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Exposing Objects in VLISP
« Reply #1 on: March 17, 2008, 06:01:41 PM »
Here's an example of how to get the AeccApp, AeccProject, and the Point Database. Note that this works with all LDT versions (ok, most. You may need to adjust it for 2004 & 2005 as I didn't have those to check). Good Luck! Note, too, that I do not use the import-library feature. I did at one time but  found I really didn't need it (it jsut allows you to call the proper & methods a wee bit easier).
Code: [Select]
  (if (and (setq key (vl-filename-base (vlax-product-key)))
   (setq vers
  (atoi (substr key
6
(- (vl-string-position (ascii ":") key) 5)
)
  )
   )
   (setq aeccVer (cond ((= vers 138) "2")
       ;;LDT3
       ;;((= vers 2008) "4");;LDT2004???
       ;;((= vers 3008) "4");;LDT2005???
       ((<= vers 4008) "4")
       ;;2006, this should use the actual values for LDT 2004 & 2005
       ;;as this will allow non-LDT's to continue
       ((= vers 5008) "6")
       ;;2007
       ((or (= vers 6008);;LDT
    (= vers 6018);;C3D LDT companion
    )
"7")        
       ;;2008
       ((alert "LDT version not supported!") nil)
)
   )
   (setq aeccString (strcat "Aecc.Application." aeccVer))
      )
    (progn
      (setq aeccapp  (vla-getinterfaceobject
       (vlax-get-acad-object)
       aeccstring
     )
    aeccProj (vlax-get aeccapp 'activeproject)
    aeccPts  (vlax-get aeccProj 'cogopoints)
      )



CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Exposing Objects in VLISP
« Reply #2 on: March 17, 2008, 06:06:40 PM »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ML

  • Guest
Re: Exposing Objects in VLISP
« Reply #3 on: March 17, 2008, 06:28:37 PM »

Jeff,
Looks good!

I tried this:
Code: [Select]
(Defun C:ActProj ()
(if (and (setq key (vl-filename-base (vlax-product-key)))
   (setq vers
  (atoi (substr key
6
(- (vl-string-position (ascii ":") key) 5)
)
  )
   )
   (setq aeccVer (cond ((= vers 138) "2")
       ;;LDT3
       ;;((= vers 2008) "4");;LDT2004???
       ;;((= vers 3008) "4");;LDT2005???
       ((<= vers 4008) "4")
       ;;2006, this should use the actual values for LDT 2004 & 2005
       ;;as this will allow non-LDT's to continue
       ((= vers 5008) "6")
       ;;2007
       ((or (= vers 6008);;LDT
    (= vers 6018);;C3D LDT companion
    )
"7")        
       ;;2008
       ((alert "LDT version not supported!") nil)
)
   )
   (setq aeccString (strcat "Aecc.Application." aeccVer))
      )
    (progn
      (setq aeccapp  (vla-getinterfaceobject
       (vlax-get-acad-object)
       aeccstring
     )
    aeccProj (vlax-get aeccapp 'activeproject)
    aeccPts  (vlax-get aeccProj 'cogopoints)
      )
      )
But I am getting an error:
malformed list on input

Did I do something wrong?

Thank you
Mark

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2140
  • class keyThumper<T>:ILazy<T>
Re: Exposing Objects in VLISP
« Reply #4 on: March 17, 2008, 07:45:26 PM »

Jeff,
Looks good!

I tried this:
Code: [Select]
(Defun C:ActProj ()
<  >
But I am getting an error:
malformed list on input

Did I do something wrong? .

Thank you
Mark

view the code in the VLIDE editor and balance the parenthesis ; you're missing a couple
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

ML

  • Guest
Re: Exposing Objects in VLISP
« Reply #5 on: March 18, 2008, 09:16:32 AM »

Jeff

I got it!
Thank you; it worked great

I didn't bother connecting to the type library either as your code got the job done.
Still, I may take a look at that for other things later.

Mark

jbuzbee

  • Swamp Rat
  • Posts: 851
Re: Exposing Objects in VLISP
« Reply #6 on: March 18, 2008, 11:16:26 AM »
ML,

When working with vertical collections, release the collection object as soon as possible, i.e. not at the end of a routine or in a clean up *error* function: as soon as you get the information you need - release it.  Don't know why, that's just the best way to handle it. 

Also, if you try to use ObjectDBX on an external database to access collections and objects I've found some limitations there as well.  Have a look at this thread:

http://www.theswamp.org/index.php?topic=17758.0
James Buzbee
Windows 8

ML

  • Guest
Re: Exposing Objects in VLISP
« Reply #7 on: March 18, 2008, 11:25:43 AM »

Hey Jb

Unfortunately I am not much of a LISP programmer, I can do a few things.
However, I am certainly open to learning more.
I looked at your code and for the most part, I did get it.

I also understand what you are saying about realizing the objects.
In VBA:
Object = Nothing

Let me as you this:
Is there a way in VLISP to run your code without saving it, apploading it, then typing in the command?
In VBA, we can run the code right from the editor, I was wondering if VLISP also had that same function?

Also, once I have the connection to the a type library in VLISP, is there a way to expose the collection in VLISP?

Thanks!
Mark

jbuzbee

  • Swamp Rat
  • Posts: 851
Re: Exposing Objects in VLISP
« Reply #8 on: March 19, 2008, 11:12:14 AM »
Quote
Is there a way in VLISP to run your code without saving it, apploading it, then typing in the command?

Yes - type VLIDE at the command line, press F1 and start learning!  :wink:

Quote
Also, once I have the connection to the a type library in VLISP, is there a way to expose the collection in VLISP?

Yes, there is a function in VLISP called "vlax-dump-object" that returns all the properties and methods of said object.  Very usefull when working with undocumented vertical objects and collections.

Use:
Code: [Select]
(vlax-dump-object 'obj T)
'obj is a valid activex object
the last argument: if nil only returns properties, if T returns properties and methods.
James Buzbee
Windows 8

ML

  • Guest
Re: Exposing Objects in VLISP
« Reply #9 on: March 19, 2008, 04:55:34 PM »

Hey JB

It didn't take a whole lot to figure out
Ctrl + Alt + E  LOL

I actually put in
Code: [Select]
(vlax-dump-object(vlax-get-acad-object) T)
Yesterday and it only returned the objects for the ACAD App
No properties or methods.

Mark

ML

  • Guest
Re: Exposing Objects in VLISP
« Reply #10 on: March 19, 2008, 04:59:54 PM »

Actually
It did give me the properties and methods.
In VBA:
Let's take Preference for example; it exposes all of the settings in Preferences
This does not
I'm sure there is a way.
I am really more into VBA, I was just dabbling with VLISP
Mark

Code: [Select]
; IAcadApplication: An instance of the AutoCAD application
; Property values:
;   ActiveDocument = #<VLA-OBJECT IAcadDocument 04fc7f84>
;   Application (RO) = #<VLA-OBJECT IAcadApplication 00c2eb8c>
;   Caption (RO) = "Autodesk Map 3D - [Drawing1.dwg]"
;   Documents (RO) = #<VLA-OBJECT IAcadDocuments 0e58e9c0>
;   FullName (RO) = "C:\\Program Files\\Autodesk Land Desktop 2006\\acad.exe"
;   Height = 998
;   HWND (RO) = 132408
;   LocaleId (RO) = 1033
;   MenuBar (RO) = #<VLA-OBJECT IAcadMenuBar 0e58ece4>
;   MenuGroups (RO) = #<VLA-OBJECT IAcadMenuGroups 0111d46c>
;   Name (RO) = "AutoCAD"
;   Path (RO) = "C:\\Program Files\\Autodesk Land Desktop 2006"
;   Preferences (RO) = #<VLA-OBJECT IAcadPreferences 0e58e92c>
;   StatusId (RO) = ...Indexed contents not shown...
;   VBE (RO) = #<VLA-OBJECT VBE 0b2a27a4>
;   Version (RO) = "16.2s (LMS Tech)"
;   Visible = -1
;   Width = 1288
;   WindowLeft = -4
;   WindowState = 3
;   WindowTop = -4
; Methods supported:
;   Eval (1)
;   GetAcadState ()
;   GetInterfaceObject (1)
;   ListArx ()
;   LoadArx (1)
;   LoadDVB (1)
;   Quit ()
;   RunMacro (1)
;   UnloadArx (1)
;   UnloadDVB (1)
;   Update ()
;   ZoomAll ()
;   ZoomCenter (2)
;   ZoomExtents ()
;   ZoomPickWindow ()
;   ZoomPrevious ()
;   ZoomScaled (2)
;   ZoomWindow (2)

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Exposing Objects in VLISP
« Reply #11 on: March 19, 2008, 05:02:31 PM »
Preferences is another object, so to see what is there you need to dump that object.  What you did in VBA can be done in Lisp with ActiveX, with regards to the properties and methods of objects.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

ML

  • Guest
Re: Exposing Objects in VLISP
« Reply #12 on: March 19, 2008, 05:05:43 PM »

Hey T.

OK, I see what you are saying, thanks
I will try dumping Preferences.

When you are saying with Active X, do you mean that I will need to connect to a type library of some sort from VLISP?

I saw how to connect to a type library but I could not expose the objects in it in VLISP

Mark

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Exposing Objects in VLISP
« Reply #13 on: March 19, 2008, 05:15:03 PM »
To use ActiveX in Lisp you just have to load the arx file, which (vl-load-com) called from a lisp file once per session will do.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Exposing Objects in VLISP
« Reply #14 on: March 19, 2008, 05:30:11 PM »
Mark,
If you really want to see how to use the methods & properties for LDT by using the type-library, go download SincPac for LDT. Sinc made this available years ago and has a bunch of neat routines. And they are not compiled into a fas or vlx so you can see what he did. It is all pretty advanced stuff, but it sounds like that's the road you are headed down. :-)

But, to use ActiveX you do not NEED to use the type-library. You just need to do as I showed using vlax-get (or vlax-get-property), etc.

Using the (vlax-import-type-library) allows you to do this:
(vla-get-activealignment aeccdoc)
instead of this:
(vlax-get aeccdoc 'activealignment)

ML

  • Guest
Re: Exposing Objects in VLISP
« Reply #15 on: March 19, 2008, 05:30:55 PM »
Hummmm
Sounds interesting!

Do you think you could give me a small sample?

I would love to try it

Thanks!

Mark

ML

  • Guest
Re: Exposing Objects in VLISP
« Reply #16 on: March 19, 2008, 05:39:05 PM »

Sounds cool Jeff!

Yes, I did do what you told me, I think?

I was able to successfully dump The ACAD Objects in VLISP
However, I was hoping it would be as easy as getting The ACAD app objects.

The other thing Jeff is that I am not yet familiar enough with LDD, but I am sure I will have some question for you in the future.

I was hoping to connect to and see different collections in VLISP as we do in ACAD.

Again, it looks like we can, it just doesn't seem as intuitive.

Now Jeff, you know that you can get to all of the Land Desktop Objects, Props and Methods in VBA, don't you?

I just set a reference to The AutoDesk Land 4.0 Type Library and voila.
The cool thing is that there is also code examples.

So, on the flip side, I was hoping to be able to see that same info in VLISP the way I can in VB.

I have to keep in mind that they are 2 different apps.

I can not expect to hit an operator (.) and get all of the associated properties as I would in VBA.

I'm sure I am missing something

Thanks!
Mark

ML

  • Guest
Re: Exposing Objects in VLISP
« Reply #17 on: March 19, 2008, 05:42:12 PM »

Hell

In VBA, I can put this bit of code in:

Code: [Select]
Public AcadApp As AcadApplication
Sub AcadAppObjs()
 
'Use this module to step through the acad app objects with the locals window open
 
'This intializes the public variable ACADApp which is used to intercept The Acad Application Objects
 Set AcadApp = ThisDrawing.Application
 
 End Sub

With Locals open, hit F8 and viola, every thing I need for the acad object.

Mark

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2140
  • class keyThumper<T>:ILazy<T>
Re: Exposing Objects in VLISP
« Reply #18 on: March 19, 2008, 05:44:14 PM »

yep, with Vlisp a little knowledge is required.  :wink:
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Exposing Objects in VLISP
« Reply #19 on: March 19, 2008, 06:05:54 PM »
Nope, you about got it right. There is no Easy Button when it comes to VLisp and the Acad Verticals. There is a lot of trial & error and using the help & VBAIDE (yes, the Object Browser there helps to figure out what is expected of the arguments). Here's a 'for instance' for you getting the Preferences you spoke of (assuming you have the AeccApp as shown previously):
Code: [Select]
(setq prefs (vlax-get aeccapp 'preferences))
(setq fileprefs (vlax-get prefs 'files))
Also, as James noted, (vlax-dump-object) can, and will be, your friend. Use it on every Object you want to know about, it will help you dive deeper into the abyss.

BTW, since you know what you can do with VBA, why the trip into lisp land?

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Exposing Objects in VLISP
« Reply #20 on: March 19, 2008, 06:15:04 PM »
With Locals open, hit F8 and viola, every thing I need for the acad object.
In the VLIDE you can rightclick on any set varaible and select  Inspect, this will give you a window which shows all of the properties of that object. See the pic where I show the Acadobject & the AeccApp.

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Exposing Objects in VLISP
« Reply #21 on: March 19, 2008, 06:29:13 PM »
Oh, and here's a link to the original SincPac

jbuzbee

  • Swamp Rat
  • Posts: 851
Re: Exposing Objects in VLISP
« Reply #22 on: March 19, 2008, 07:14:52 PM »
Quote
BTW, since you know what you can do with VBA, why the trip into lisp land?

Because unlike Lisp - VBA's lifespan is nearing it's end!!!  And with OpenDCL you can do more, yes more, than basic VBA!!!   ;-)
James Buzbee
Windows 8

ML

  • Guest
Re: Exposing Objects in VLISP
« Reply #23 on: March 20, 2008, 10:25:00 AM »

Jeff!

Thank you very much!
Now that is what I am talking about Willis... Remember Arnold from Different Strokes? :)

Cool, I will definitely be using inspect.
And thanks for the pic, I will save that as a reference until I get use to it.

And, I did download sinc pak, thank you for that. I don't know what to do with it yet but I am sure I will learn with time.

Now, the big question, why VLISP?
My easy answer could be, why not.
However, I will elaborate....
My current boss is a very good LISP programmer, he has been at it for app. 20 years.
We do some VBA projects; may be not as much as I would like, but that is OK because now that I have been forced to learn some LISP, I am seeing great value in it, for some things.

Now, if I am going to do LISP as well as VBA, I think that I would prefer to have the capabilities of VLISP then just using a text editor...especially because I need the debugging tools. And realizing that I can access Objects, props and methods in there.

Mark


ML

  • Guest
Re: Exposing Objects in VLISP
« Reply #24 on: March 20, 2008, 10:30:43 AM »

Now JB

Quote
yep, with Vlisp a little knowledge is required. 

You are absolutely right but you are not saying that knowledge is not needed in VBA are you?
Man, I have spent the last 3 years or so learning VBA and still feel like I am barely scratching the service.

That little bit of code that I dropped to see all of the objects in VBA is not rockets science but for someone who did not realize that you can get all of that info with that little bit of code; that is very good info.

So, is a fact that VBA is going to be history?

Thanks to a friend, I have a pdf from AU
It shows how to convert your existing VBA projects to .net with very little effort.

That does not mean that we will not need to learn .net but it does mean that we can have our VBA projects up and running quickly if push came to shove.

If you don't have .net or access to it; you can download VB Express 2008 for free from Microsoft.

With that you can start learning .net.

May be I should dive it

Mark

Mark