TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Grrr1337 on December 12, 2016, 08:59:30 AM

Title: (vlax-get-or-create-object prog-id)
Post by: Grrr1337 on December 12, 2016, 08:59:30 AM
Hi guys,
I'm having problem with the prog-id argument on vlax-get-or-create-acad-object (https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2016/ENU/AutoCAD-AutoLISP/files/GUID-7AFF597F-D630-4489-8349-94EF67CCE1F0-htm.html):
Code: [Select]
_$ (setq NP++ (vlax-get-or-create-object "Notepad++.Application.722"))
nil
_$
Assuming that the info I need for the "<Vendor>.<Component>.<Version>" can be found here:
(https://s27.postimg.org/lowzz966r/NP_Props.jpg)
Can anyone taught me how to properly use it (the prog-id argument) ? - for example I want to obtain objects from other applications like: chrome, revit, 3ds max ... for exploration purposes  :police:
Title: Re: (vlax-get-or-create-object prog-id)
Post by: roy_043 on December 12, 2016, 09:24:58 AM
Not all programs support ActiveX. In the case of Notepad++ a plugin seems to be required:
https://sourceforge.net/projects/nppactivexplugin
Title: Re: (vlax-get-or-create-object prog-id)
Post by: Grrr1337 on December 12, 2016, 10:31:54 AM
Thanks Roy,
But is there a rule how populate this argument? For example none of these succeeded:
Code: [Select]
_$ (setq 3DSmax (vlax-get-or-create-object "3dsMax.Application.17.0.630.0"))
nil
_$ (setq 3DSmax (vlax-get-or-create-object "3ds Max.Application.17"))
nil
_$ (setq 3DSmax (vlax-get-or-create-object "3ds Max.Application.17`.0`.630`.0"))
nil
_$ (setq 3DSmax (vlax-get-or-create-object "3dsMax.Application.17`.0`.630`.0"))
nil
_$ (setq 3DSmax (vlax-get-or-create-object "3ds Max.Application"))
nil
_$ (setq 3DSmax (vlax-get-or-create-object "3dsMax.Application"))
nil
_$
(https://s23.postimg.org/5g7mlw7x7/3_DSmax_Props.jpg)
Is the above picture the right way for obtaining that info for vlax-***-object functions or I misunderstand something and must look somewhere else? (generally speaking)
And I know that it supports ActiveX, because of this documentation (http://docs.autodesk.com/3DSMAX/15/ENU/MAXScript-Help/index.html?url=files/GUID-F9BDCDFD-5C2D-42ED-A840-184795A2E057.htm,topicNumber=d30e648360).
Title: Re: (vlax-get-or-create-object prog-id)
Post by: MP on December 12, 2016, 12:16:42 PM
Kinda related ... you might find this useful for finding ProgIDs without having to resort to searching via RegEdit:

Code: [Select]
(defun _FindProjIDs ( pattern )
    (   (lambda ( pfx sfx pattern )
            (vl-sort
                (vl-remove-if-not
                    (function
                        (lambda (x)
                            (and
                                (eq 'str (type x))
                                (wcmatch (strcase x) pattern)
                            )
                        )
                    )
                    (mapcar
                        (function
                            (lambda (x)
                                (vl-registry-read (strcat pfx x sfx))
                            )
                        )
                        (vl-registry-descendents pfx)
                    )
                )
               '<
            )       
        )
        "HKEY_CLASSES_ROOT\\CLSID\\"
        "\\ProgID"
        (strcase pattern)
    )
)

e.g.

(_FindProjIDs "*objectdbx*") ;; I don't have 3D max

>>

(
    "ObjectDBX.AxDbDocument.17"
    "ObjectDBX.AxDbDocument.18"
    "ObjectDBX.AxDbDocument.19"
    "ObjectDBX.AxDbDocument.20"
)


FWIW, cheers.
Title: Re: (vlax-get-or-create-object prog-id)
Post by: Grrr1337 on December 12, 2016, 01:39:22 PM
That looks very handy MP!
Althoough I didn't expected that obtaining a COM from another software is such a pain in the @$$!
Perhaps I need start studying .NET for a better understanding & achieving this task (ATM I'm completely boxed with lisp).

Anyway I'm leaving this (http://help.autodesk.com/view/3DSMAX/2016/ENU/?guid=__files_GUID_9D7A5F50_F1FB_407A_A70E_878D6CAFEEE7_htm) for further interests.

EDIT: BTW Roy, your advice worked:
Code: [Select]
_$ (setq NP++ (vlax-get-or-create-object "NotepadPlusPlus.Application"))
#<VLA-OBJECT INppApplication 000000211d68f438>
_$ (vlax-dump-object NP++ T)
; INppApplication: This interface represents the complete Notepad++ application.
; Property values:
;   editors (RO) = ...Indexed contents not shown...
;   menu (RO) = ...Indexed contents not shown...
; Methods supported:
;   executeScriptFromFile (3)
;   executeScriptFromString (3)
;   messageBox (3)
;   quit ()
T
_$
I appreciate your help!