Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Problem determining componentdefinition.type with apprentice

bshbsh
Collaborator

Problem determining componentdefinition.type with apprentice

bshbsh
Collaborator
Collaborator

Hi,

I'm experimenting with vb.net and apprentice, by re-implementing existing VBA code. I'm new to this...

I have found a problem: I use select.. case to determine componentdefinition.type and do different code accordingly. The problem is a weldment type document, is being identified as a plain assembly type document

 

Select Case ApprenticeDoc.ComponentDefinition.Type
  Case InventorApprentice.ObjectTypeEnum.kPartComponentDefinitionObject, InventorApprentice.ObjectTypeEnum.kSheetMetalComponentDefinitionObject
    ...
  Case InventorApprentice.ObjectTypeEnum.kAssemblyComponentDefinitionObject
    ... Weldments go this path as well!!!
  Case InventorApprentice.ObjectTypeEnum.kWeldmentComponentDefinitionObject
    ...
End Select

 

What am I doing wrong? This used to work in VBA. Can apprentice not do this?

 

Edit: I need the Weldbead.Material which does not seem to exist in Apprentice. So I assume it can not handle Weldments properly? That is bad.

0 Likes
Reply
Accepted solutions (1)
825 Views
14 Replies
Replies (14)

JhoelForshav
Mentor
Mentor

Hi @bshbsh 

I don't know for sure about apprentice, but I think you should use the documents subtype.

Something like this:

 

Select Case ApprenticeDoc.SubType
  Case "{4D29B490-49B2-11D0-93C3-7E0706000000}", "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" 'Part, Sheet Metal
    '...
  Case "{E60F81E1-49B3-11D0-93C3-7E0706000000}" 'Assembly
    '... 
  Case "{28EC8354-9024-440F-A8A2-0E0E55D635B0}" 'Weldment Assembly
    '...
End Select

bshbsh
Collaborator
Collaborator

Document Subtype doesn't seem to be accessible via Apprentice.

But since Material properties aren't accessible either, the whole things falls to its face.

And so do I. 😞 I thought rewriting the existing VBA code in vb.net is going to be easier.

0 Likes

marcin_otręba
Advisor
Advisor

I think you can go trough FilesEnumerator ->File.Type. Also material you can get from property sets from apprentice.

Maybe if you could describe what you want to get from your code it will be easier to help.

 

 

0 Likes

bshbsh
Collaborator
Collaborator

Through file.type? Can you show me how? Don't think that is possible.

Also the iproperties.material returns empty for both plain assemblies and weldments. for me what appears in the BOM as material is the Weldbead material in case of weldments. That's what I need.

All I am doing is just collecting a bunch of metadata from files and put them in a database. I want to do this through a separate program and using apprentice, not running a vba code from inside inventor. But if apprentice can not retrieve a whole bunch of info I need, then it is useless.

Also, in general, I don't find many of the Enums in VS2019. Like, where are the BOM View Type enums?

0 Likes

marcin_otręba
Advisor
Advisor

so why you bother with apprentice ? use inventor vba add in instead, or standalone app but using full inventor api instead of apprentice.

0 Likes

marcin_otręba
Advisor
Advisor

And about filesenumerator it should be accessible from apprentice:

marcin_otręba_0-1591628323110.png

 

0 Likes

bshbsh
Collaborator
Collaborator

why? obviously to get up-to-date info/metadata either directly from inventor files, or through a database on computers/coworkers who do not have inventor.

0 Likes

marcin_otręba
Advisor
Advisor
Accepted solution

ok,

 then you can create addin inside inventor to save all what you need in customproperties for example and then use apprentice to get that data from it. you can store subtype as well. But i checked and you can get subtype and Weld Material from iproperties as well, i think all iproperties are reachable from apprentice.

 

List of iproperties:

Inventor Summary Information Title
Inventor Summary Information Subject
Inventor Summary Information Author
Inventor Summary Information Keywords
Inventor Summary Information Comments
Inventor Summary Information Last Saved By
Inventor Summary Information Revision Number
Inventor Summary Information Thumbnail
Inventor Document Summary Information Category
Inventor Document Summary Information Manager
Inventor Document Summary Information Company
Design Tracking Properties Creation Time
Design Tracking Properties Part Number
Design Tracking Properties Project
Design Tracking Properties Cost Center
Design Tracking Properties Checked By
Design Tracking Properties Date Checked
Design Tracking Properties Engr Approved By
Design Tracking Properties Engr Date Approved
Design Tracking Properties User Status
Design Tracking Properties Material
Design Tracking Properties Part Property Revision Id
Design Tracking Properties Catalog Web Link
Design Tracking Properties Part Icon
Design Tracking Properties Description
Design Tracking Properties Vendor
Design Tracking Properties Document SubType
Design Tracking Properties Document SubType Name
Design Tracking Properties Proxy Refresh Date
Design Tracking Properties Mfg Approved By
Design Tracking Properties Mfg Date Approved
Design Tracking Properties Cost
Design Tracking Properties Standard
Design Tracking Properties Design Status
Design Tracking Properties Designer
Design Tracking Properties Engineer
Design Tracking Properties Authority
Design Tracking Properties Parameterized Template
Design Tracking Properties Template Row
Design Tracking Properties External Property Revision Id
Design Tracking Properties Standard Revision
Design Tracking Properties Manufacturer
Design Tracking Properties Standards Organization
Design Tracking Properties Language
Design Tracking Properties Defer Updates
Design Tracking Properties Size Designation
Design Tracking Properties Categories
Design Tracking Properties Stock Number
Design Tracking Properties Weld Material
Design Tracking Properties Mass
Design Tracking Properties SurfaceArea
Design Tracking Properties Volume
Design Tracking Properties Density
Design Tracking Properties Valid MassProps
Design Tracking Properties Flat Pattern Width
Design Tracking Properties Flat Pattern Length
Design Tracking Properties Flat Pattern Area
Design Tracking Properties Sheet Metal Rule
Design Tracking Properties Last Updated With
Design Tracking Properties Sheet Metal Width
Design Tracking Properties Sheet Metal Length
Design Tracking Properties Sheet Metal Area
Design Tracking Properties Material Identifier
Design Tracking Properties Appearance
Design Tracking Properties Flat Pattern Defer Update

bshbsh
Collaborator
Collaborator

Thanks, those iProps seem to work for what I need to do.

0 Likes

bshbsh
Collaborator
Collaborator

I still can not get a few things through apprentice, such as the RangeBox. I need it for the external dimensions LxWxH. Do you have any idea?

0 Likes

marcin_otręba
Advisor
Advisor

as i already mentioned, best approach would be setting up rule or adding wchich will write all needed (and not accessible trough apprentice) data into custom iproperty wehen document is saved. I have it done like this in all companies I work with and it works fine.

0 Likes

bshbsh
Collaborator
Collaborator

and as i already mentioned, that is precisely what i do here as well, but i need to get data from approx. hundred thousand ancient inventor files as well, that do not have those custom iproperties set, and I don't want to open them all in inventor, i want to get the info using apprentice, so that i can use my external application to read the matadata i need, without it being opened (and depending) on inventor. most of the metadata comes from custom iproperties anyway, but i can not just add more to my liking. also, adding those custom iproperties to hundred thousand ancient files would require opening the files in inventor anyway.

0 Likes

marcin_otręba
Advisor
Advisor

I have only part of picture from your situation, so i may not always give you best answer.

But i also have such situation with introducing new software to company and then i run addin wchich opened doc after doc and performed desired work on it. i know it will consume time but it is best what you can get, you will not have data trough apprentice anyway due fact that you cant use range box.

 

also i fount this thread but i dont know if it will not work trough apprentice:

 

https://forums.autodesk.com/t5/inventor-customization/getting-the-part-sizes-with-visual-basic-appre...

 

0 Likes

bshbsh
Collaborator
Collaborator

That only seems to work with parts, assemblies do not have surfacesbodies. Also I'm not sure how it would work on multibody parts.

0 Likes