Author Topic: Vlisp to use AcDbHostApplicationServices  (Read 5849 times)

0 Members and 1 Guest are viewing this topic.

CADDOG

  • Newt
  • Posts: 82
  • wishbonesr
Vlisp to use AcDbHostApplicationServices
« on: November 20, 2012, 10:45:42 PM »
Any way for Vlisp to get ahold of AcDbHostApplicationServices or the .net wrapped HostApplicationServices?

Every turn I make seems like there's something to the notion, but then...
Not sure if I'm barking at a shadow.


Dumping vla functions gives evidence that there are methods exposed by activeX (vla-getpassword, vla-getremotefile, vla-putremotefile, etc), but what object in vlisp from vlax-get-acad-object down are these applicable to?  Started looking at interface objects and even Utility looked promising, but once again, that ellusive shadow.

Any thoughts?


BlackBox

  • King Gator
  • Posts: 3770
Re: Vlisp to use AcDbHostApplicationServices
« Reply #1 on: November 21, 2012, 12:56:16 AM »
LispFunction Method?

What is it exactly that you're trying to do with or get from AcDbHostApplicationServices, that you are unable to do via existing LispFunctions?
"How we think determines what we do, and what we do determines what we get."

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Vlisp to use AcDbHostApplicationServices
« Reply #2 on: November 21, 2012, 06:52:46 AM »
Dumping vla functions gives evidence that there are methods exposed by activeX (vla-getpassword, vla-getremotefile, vla-putremotefile, etc), but what object in vlisp from vlax-get-acad-object down are these applicable to?

Code - Auto/Visual Lisp: [Select]
  1. (vla-get-password
  2.     (setq securityparams
  3.             (strcat "autocad.securityparams." (itoa (atoi (getvar 'acadver))))
  4.         )
  5.     )
  6. )
  7. (vlax-release-object securityparams)
Code - Auto/Visual Lisp: [Select]
  1.     <URL>
  2.     <Local File>
  3.     <Ignore Cache>
  4. )
Code - Auto/Visual Lisp: [Select]

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Vlisp to use AcDbHostApplicationServices
« Reply #3 on: November 21, 2012, 08:42:21 AM »
Dumping vla functions gives evidence that there are methods exposed by activeX (vla-getpassword, vla-getremotefile, vla-putremotefile, etc), but what object in vlisp from vlax-get-acad-object down are these applicable to?
Have you tried using the ActiveX/VBA reference? Here's an online version: http://entercad.ru/acadauto.en/

Then to "translate" the VBA examples into VLisp: http://docs.autodesk.com/ACD/2011/ENU/filesALG/WS73099cc142f4875516d84be10ebc87a53f-7c00.htm
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

BlackBox

  • King Gator
  • Posts: 3770
Re: Vlisp to use AcDbHostApplicationServices
« Reply #4 on: November 21, 2012, 08:53:33 AM »
Save you the trouble....

Property:
vla-get-password



Methods:
vla-getremotefile, and vla-putremotefile
"How we think determines what we do, and what we do determines what we get."

CADDOG

  • Newt
  • Posts: 82
  • wishbonesr
Re: Vlisp to use AcDbHostApplicationServices
« Reply #5 on: November 21, 2012, 12:35:03 PM »
LispFunction Method?

What is it exactly that you're trying to do with or get from AcDbHostApplicationServices, that you are unable to do via existing LispFunctions?

I want to set/get the workingdatabase  :ugly:
It's more of an experiment, in an attempt to use pure lisp (no non-native install external requirements).  Well kinda pure.  Like tap water in a Voss bottle  ;-)
Remember my post about trying to modify attributes via dbx, and the problems that arise.  It comes down to internal calculations that go into determining the location of a attribute display being only available to the "workingdatabase".  I got it to work, but had to use a LispFunction that would set the workingdatabase to the dbx database, perform the attribute modification, and then return the workingdatabase to the active document.  My goal is to eliminate the requirement for .net, and set the workingdatabase from vlisp.
Have you tried using the ActiveX/VBA reference? Here's an online version: http://entercad.ru/acadauto.en/
I brain farted last night, and forgot about that (was using local http based help searches). My acad 2012 doesn't have the chm installed.  Found 2010 version that has that model reference, not to mention this was handing around  :roll:


Nothing in the reference material for hostapplication services or setworkingdatabase.
So am I sol?

Thanks Lee, for direct examples.  Not being sarcastic.  I learn from examples, and now I know exactly what those were for.

Since AcDbHostApplicationServices is not available via vla-, is there a way for VLisp to import the library that defines AcDbHostApplicationServices (is there even a lib available in ActiveX for it)?  I've gone in a few directions, and tried importing the type lib for acax18ENU.tlb, and axdb18enu.tlb.  Both appear to generate the same function lists, which mirror all of vla- functions.

Looking at .net's references acdbmgd.dll defines the wrapper for it HostApplicationServices, but pretty sure I can't use .net assemblies???  Then trying to track down AcDbHostApplicationServices led me to dbapserv.h.  Now we enter C/C++ and I get light headed.
Note: I only discovered you could import a type lib a week ago Bought the ebook VLisp Developer's Bible last night..., so once again, I find myself in unfamiliar territory.
« Last Edit: November 21, 2012, 04:15:02 PM by CADDOG »

BlackBox

  • King Gator
  • Posts: 3770
Re: Vlisp to use AcDbHostApplicationServices
« Reply #6 on: November 21, 2012, 01:42:31 PM »
"How we think determines what we do, and what we do determines what we get."

CADDOG

  • Newt
  • Posts: 82
  • wishbonesr
Re: Vlisp to use AcDbHostApplicationServices
« Reply #7 on: November 21, 2012, 02:02:03 PM »
I'm not really a fan of David's work or anything.  :lol:

Yup, came across that post, and is the reason I purchased.  You mentioned it somewhere else as well, and was like, "It's $7. Just saying." lol.
That spoke to me.

BlackBox

  • King Gator
  • Posts: 3770
Re: Vlisp to use AcDbHostApplicationServices
« Reply #8 on: November 21, 2012, 02:03:01 PM »
I'm not really a fan of David's work or anything.  :lol:

Yup, came across that post, and is the reason I purchased.  You mentioned it somewhere else as well, and was like, "It's $7. Just saying." lol.
That spoke to me.

Glad to hear it - enjoy the book!
"How we think determines what we do, and what we do determines what we get."

CADDOG

  • Newt
  • Posts: 82
  • wishbonesr
Re: Vlisp to use AcDbHostApplicationServices
« Reply #9 on: November 21, 2012, 03:08:48 PM »
I think I want something like this.

Code - Auto/Visual Lisp: [Select]
  1. (setq hostservicename (strcat "autocad.applicationservices." (itoa (atoi (getvar 'acadver)))))
  2. ;;;or
  3. (setq hostservicename "autocad.applicationservices")
  4. ;;;but there's no registered class by either name.
  5.                  hostservicename))
  6. ;;;or
  7. (setq acdbmgd-lib "C:\\ObjectARX 2012\\inc\\AcDbMgd.dll")
  8.   :tlb-filename acdbmgd-lib
  9.   :methods-prefix "mgdm-"
  10.   :properties-prefix "mgdp-"
  11.   :constants-prefix "mgdc-")
  12.  
...but all fail.

I feel like, if .net can look at the AcDbMgd.dll, and get the type lib, then why can't vlisp?  And even if it can, then how would I get the hostapplicationservices anyways.  It seems like there's a way, just haven't found it yet, to either use the .net wrapped HostApplicationServices, or to go down to the AcDbHostApplicationServices.
Or am I just getting criss-crossed with ActiveX boundaries???
« Last Edit: November 21, 2012, 03:14:34 PM by CADDOG »

BlackBox

  • King Gator
  • Posts: 3770
Re: Vlisp to use AcDbHostApplicationServices
« Reply #10 on: November 21, 2012, 05:38:02 PM »
I've honestly never tried importing any assembly (dll) as a typed library before, but only as a speculative guess, I am inclined to suggest that be an issue of managed vs. COM exposed, no?

*hopes someone much smarter than I jumps in to clarify*
"How we think determines what we do, and what we do determines what we get."

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Vlisp to use AcDbHostApplicationServices
« Reply #11 on: November 21, 2012, 06:23:44 PM »
I'm not really a fan of David's work or anything...

Haven't read this (saw it on linkedin today) but ya'll may be interested.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Vlisp to use AcDbHostApplicationServices
« Reply #12 on: November 22, 2012, 12:11:21 AM »
Nothing in the reference material for hostapplication services or setworkingdatabase.
So am I sol?
Well, no you wouldn't find it there. ADesk didn't do a 1 to 1 mapping of the ARX libraries to ActiveX ... not even similar to the DotNet mapping from ARX. Thus you tend to find gaps in the ActiveX/COM libs (especially with newer stuff since it hasn't been updated since around 2006/7).
 
What I was actually suggesting is to search for the method / property name on that site (or your local copy of the CHM if you have it). Then you would have found the containing object and would much more easily have figured out how to get to them through VLisp.
 
As for COM not working on DotNet DLL's ... this is generally true. It is possible for the developer of the DotNet DLL to have registered the DLL as COM-Visible as well. But that needs to have (at least) a compile-time setting (and implement some interface classes as well). I have "heard" if a COM-to-Net bridge library somewhere, but for the life of me I can't find it now. Basically it's a normal COM-DLL which uses DotNet inside to use Reflection on other Net-DLL's, then dynamically allow for calling properties / methods. All I seem to find is the DotNet-Java bridge ... but that's not it.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

CADDOG

  • Newt
  • Posts: 82
  • wishbonesr
Re: Vlisp to use AcDbHostApplicationServices
« Reply #13 on: November 26, 2012, 10:18:52 AM »
I'm not really a fan of David's work or anything...

Haven't read this (saw it on linkedin today) but ya'll may be interested.

Not bad.  I've only stared at the samples plain text file on my phone for an hour or so, and this will be great for me who wasn't very good at geometry.  Also, I struggled with the transformation matrix.  Seeing these examples, I think I'll get the concept shortly.

Thank you for that link.

CADDOG

  • Newt
  • Posts: 82
  • wishbonesr
Re: Vlisp to use AcDbHostApplicationServices
« Reply #14 on: November 26, 2012, 10:39:46 AM »
What I was actually suggesting is to search for the method / property name on that site (or your local copy of the CHM if you have it). Then you would have found the containing object and would much more easily have figured out how to get to them through VLisp.
This method you described is the way I expected to discover access to this class, My first external library usage was excel (primary examples from afralisp), then into other registrered classes to emulate tasks that were previously executed in powershell (but needed during a cad session, not to mention the overhead work to get powershell working at the user level).
But as you mentioned, this one's not available.

If it can possibly be obtained, then I can see this discovery, changing the face of quite a few lisp programs that forgoe dbx and revert to opening files from a script.

At this time I'm relying on an extremely simple .net LispFunction to set the workingdatabase to the supplied dbx database being processed before changing attributes values, and then calling the LispFunction again after attribute modification is complete, to set the workingdatabase back to the original database.