get assembly file path from inside part

get assembly file path from inside part

cadman777
Advisor Advisor
897 Views
10 Replies
Message 1 of 11

get assembly file path from inside part

cadman777
Advisor
Advisor

Hey guys ....

Would someone please direct me to a link that shows how to get a part's top-level Assembly PATH from w/in that part using and iLogic rule?

I spent the last hour looking online and didn't find anything.

Thanx!

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes
Accepted solutions (2)
898 Views
10 Replies
Replies (10)
Message 2 of 11

JhoelForshav
Mentor
Mentor

Hi @cadman777 

Since the same part can be in an infinite number of assemblies, a part doesn't contain any data of which assembly it is inside. It's just how Inventor works...

0 Likes
Message 3 of 11

cadman777
Advisor
Advisor

OK, I just found this:

https://forums.autodesk.com/t5/inventor-customization/ilogic-browse-to-select-a-file/td-p/3651516

 

Now if someone can link me to the 'controls' for file dialogs, maybe I can come up with a way to tap into the filepath of the assembly through it?


I figure it this way: If you can RMB on a file (iam or ipt) in windows explorer to see the iproperties of that file, then why can't you do it w/ilogic?

 

I just need to be pointed to where the explanation of the FILE DIALOG function is, so I can try stuff to see if I can make it work.

 

TIA ...

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes
Message 4 of 11

WCrihfield
Mentor
Mentor

There is a sample code within the Snippets > Custom tab > My Snippets collection, that shows how to use a File Selection Dialog.

Dim oFileDlg As inventor.FileDialog = Nothing
InventorVb.Application.CreateFileDialog(oFileDlg)
'oFileDlg.Filter = "Inventor Files (*.iam;*.ipt)|*.iam;*.ipt|All Files (*.*)|*.*"
'oFileDlg.Filter = "XML Files (*.xml)|*.xml"
'oFileDlg.Filter = "Excel Files (*.xls;*.xlsx)|*.xls;*.xlsx"
'oFileDlg.Filter = "Text Files (*.txt;*.csv)|*.txt;*.csv"
'oFileDlg.Filter = "SAT Files (*.sat)|*.sat"
'oFileDlg.Filter = "IGES Files (*.igs)|*.igs"
oFileDlg.Filter = "Step Files (*.stp)|*.stp"
'oFileDlg.DialogTitle = "Select a File"
oFileDlg.InitialDirectory = ThisDoc.Path
oFileDlg.CancelError = True
On Error Resume Next
oFileDlg.ShowOpen()
If Err.Number <> 0 Then
MessageBox.Show("File not chosen.", "Dialog Cancellation")
ElseIf oFileDlg.FileName <> "" Then
selectedfile = oFileDlg.FileName
MessageBox.Show("File " & selectedfile & " was selected.", "Dialog Selection Made")
End If

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 11

WCrihfield
Mentor
Mentor

There is also this:

 

Dim oPDoc As PartDocument = ThisApplication.ActiveDocument
Dim oRefDocs As DocumentsEnumerator = oPDoc.ReferencingDocuments

 

I know it's not exactly what you're looking for, because is searches 'in-memory' documents, and not the whole file system, but it goes along with the subject of the title of this post.

 

@JhoelForshav

I don't currently use Vault, so I'm not familiar enough with it, but I was thinking there was a way to use Vault to find which assemblies a part is being used (referenced) in?  I don't even know if @cadman777 , or you have it or not.  Just thought it might be appropriate for this post.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 6 of 11

JhoelForshav
Mentor
Mentor

@WCrihfield 

You are right. In vault you can see which assemblies a part is being used in. But vault doesn't get that data from the partfile, it gets it from the checked in assembly structures.

If the data would be stored in the part, that would mean that the part has to be checked out, saved and checked in again each time you place it into an assembly.

0 Likes
Message 7 of 11

cadman777
Advisor
Advisor

WC,

Thanx for this info.

I don't use Vault, so that's not an option or problem.

You're right, I was hoping to get a cut-sheet on how FileDialog works.

I'm still novice in this, so gettin the low-down on the controls really helps.

Thought I might find it on MS' VBA Reference web site, but that's MS Office specific, so it didn't help much.

Is there anything in the Inventor VBA editor?
I didn't find anything.

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes
Message 8 of 11

WCrihfield
Mentor
Mentor
Accepted solution

Here's the sample code for the VBA version that is found in the online help.

File Dialog API Sample 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 9 of 11

cadman777
Advisor
Advisor

OK, here's what I did ...

Added this couple lines to my rule (modified from this CurtisW post):

https://forums.autodesk.com/t5/inventor-customization/ilogic-browse-to-select-a-file/td-p/3651516

 

'Open a FileDialog to get the Top-Level Assembly's PATH and use it to make DXF folder
Dim oFileDlg As Inventor.FileDialog = Nothing
InventorVb.Application.CreateFileDialog(oFileDlg)
oFileDlg.InitialDirectory = oOrigRefName
oFileDlg.CancelError = True
On Error Resume Next
oFileDlg.ShowOpen()
If Err.Number <> 0 Then
    Return
    ElseIf oFileDlg.FileName <> "" Then
    selectedfile = oFileDlg.FileName
End If
Dim SETFilePath As String = Left(oFileDlg.FileName, Len(oFileDlg.FileName) - 4)
Dim New_Folder_Path As String = SETFilePath & "-DXF Files" & "\"
	My.Computer.FileSystem.CreateDirectory(New_Folder_Path)

 

Guess what?
It worked!

👍

 

This is my first 'success', but it took me 2 days to cobble together.

I learned a ton the last 2 days, lemme tell ya.
I'm really starting to get the hang of segmenting my code in chunks, and annotating each piece w/a descriptive comment.

 

Thanx for all the help!

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes
Message 10 of 11

cadman777
Advisor
Advisor

WC,

 

Thanx for that link.

I keep forgetting to tap into that KB info, b/c there's so much else to be looked at.

 

Here's what I wish the KB info was formatted like:

https://docs.microsoft.com/en-us/office/vba/Language/Reference/user-interface-help/right-function

 

That's what I was looking for.

That's how the AutoLISP books were like back in the day.

 

Anyways, thanx again for helping!

 

My next task is figuring out how to run this Rule from another Rule so it processes all the opened sheetmetal part files. I got a few posts from in here that show how to do it w/Drawing files. Now I just gotta figure out how to adapt them to Sheetmetal files.

 

One thing I have to say is, this forum is a treasure trove of help!

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes
Message 11 of 11

cadman777
Advisor
Advisor
Accepted solution

Your link helped me find what I wanted:

https://help.autodesk.com/view/INVNTOR/2021/ENU/?guid=GUID-A28C2FDF-9DE0-4914-95D9-376478E90FF6

https://help.autodesk.com/view/INVNTOR/2021/ENU/?guid=GUID-D8EBEFF2-9103-4A97-8BF2-462821CDC771

 

 

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes