Author Topic: Exposing Objects in VLISP  (Read 6121 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)