VBA Error 445 while accessing Part properties

VBA Error 445 while accessing Part properties

LexmanG
Participant Participant
684 Views
7 Replies
Message 1 of 8

VBA Error 445 while accessing Part properties

LexmanG
Participant
Participant

Hi. I got strange issue while trying to get Part or iPart data via Apprentice server under Excel x64.

First i tried to use this example (https://forums.autodesk.com/t5/inventor-programming-ilogic/vba-ipart-value-from-ipart-table/m-p/5411...) but got error on this line:

Set oRow = oMember.Row

Then I wrote simple example sub:

 

    Dim app As ApprenticeServerComponent
    Dim oUParams As Object
    Dim oDoc As ApprenticeServerDocument
    Dim oDef As ComponentDefinition
    Dim oiPart As iPartMember
    Dim o_ As Object        
        
    Set app = New ApprenticeServerComponent
    Set oDoc = app.Open("D:\test.ipt")
    Set oDef = oDoc.ComponentDefinition
    Set o_ = oDef.Parameters  <- ERROR 445 Here "Object doesn't support this action"

 

I found a lot of identical examples that worked for others, so I think the trouble is not in the code.

Inventor 2023.

I tried to install apprentice 2023, and 2024. No result.

 

Any ideas? Where am I wrong?

0 Likes
Accepted solutions (1)
685 Views
7 Replies
Replies (7)
Message 2 of 8

batuhanozmen98
Enthusiast
Enthusiast

Hi did you try to

define o_ As Parameters

"Dim o_ As Parameters"

0 Likes
Message 3 of 8

LexmanG
Participant
Participant

Yes. The same result.

I dunno if it's important, but in "Locals" window under debugger I have "Application-defined or Object-defined error" in value of the "Parameters" field. And may other parameters too.

 

ucstkrd_0-1710489861401.png

 

0 Likes
Message 4 of 8

WCrihfield
Mentor
Mentor

Hi @LexmanG.  I am honestly not that familiar with Apprentice Server, but I have read several documentations about it and seen many forum discussions about it.  I am also relatively good with VBA, due to using it over the years.  I do not think the two were meant to be used together.  Apprentice is for accessing Inventor stuff from a standalone EXE type application, not for use in Inventor add-ins, VBA macros, or iLogic rules.  When using VBA, you already have 'normal' access to the regular Inventor application, instead of through Apprentice.  Take a look at the following link, which takes you to a web page within Inventor's online help documentation, where it talks about Apprentice Server.

https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-F2A12822-98DE-4638-B1C7-6BEEF821D50A 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 8

LexmanG
Participant
Participant

I've read this earlier. The main apprentice goals is a) speed!!! b) no need to install Inventor itself.

And the link doesn't say that Apprentice cannot be used within office VBA (but it cannot be used inside Inventor iLogic and macros as I understand).

There are a lot of Excel/Apprentice examples in internet, but I dont understand why I have issues using it.

Also I dont think there is any difference in using ActicveX between, say, Visual Studio exe app project and VBA macro...

0 Likes
Message 6 of 8

A.Acheson
Mentor
Mentor

Does this code work for a regular part or assembly instead of an ipart? Are you able to access the ipart member parameters manually through the UI? Member files are restricted in user access because the information is held in the factory files. I am not sure I have been able to open the parameter window in the UI. Are you connected to the apprentice server, ate you able to return the filename of document opened? 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 7 of 8

LexmanG
Participant
Participant

Yes, of course. The assembly is fully accesible including the parts and iParts.

And I read basic file(s) properties - the Inventor properties i mean.

0 Likes
Message 8 of 8

LexmanG
Participant
Participant
Accepted solution

I spent some time trying to solve this problem and decided to refactor the code to use the Inventor core library instead of Apprentice.
And now everything works fine - all properties and methods are available.
It's likely that Appreintice is a stripped-down version of the base API, and that's the reason why some of the internal data is not accessible (but is still accessible through the object model, although it doesn't work).
The code speed is lower, but this is the lesser evil.

0 Likes