I have an assembly that contains various parts.
I export these parts as a step file.
Those step files are written to a specific folder.
'- - - - - - - - - - - - -STEP setup - - - - - - - - - - - -
oPath = "Z: \ Uni_Link \ Import \ Stepfiles"
'get STEP target folder path
oFolder = oPath & "\" & iProperties.Value ("Project", "Stock Number") & "STEP Files"
-----------------------------------------------------------------------------------------
I need this location in my parts list.
That parts list is saved as a csv file.
That csv file is loaded in another program.
That program looks at the folder location where the step files are.
Those step files are then loaded into the program.
Is it possible to get that folder location from each part in the assy in the parts list after i exported the step files.
Solved! Go to Solution.
Solved by jostroopers. Go to Solution.
Is the CSV file exported directly from a PartsList that is placed on a sheet in a drawing document?
Is this CSV file exported before or after the model files are exported to STEP files?
If the CSV files are exported after the model files are exported to STEP, and the CSV files are exported directly from an instance of a PartsList on a sheet, then:
Then later if the models have already been exported, but the paths weren't written to those custom iProperties within the model files, and you want to solve it with code alone, you would have to build and run a script that searches through the target directory for the files with their part numbers, then return the FullFileName of the found files to the custom iProperty. Hopefully at least the "Stock Number" iProperty is filled in within the model files, so you can use it in the search path, otherwise you may have to start your search in a higher directory, and include sub directories.
Wesley Crihfield
(Not an Autodesk Employee)
To answer your first question, the csv will be exported that is placed on a sheet in a Inventor dwg drawing document.
The second answer, the csv will be exported after the step files are exported.
I'm still not sure if the custom iProperty already exists in all the referenced documents within the main assembly, or not. Or if you are expecting a solution that will create this custom iProperty within all those referenced documents. If you want that custom property created, then in order to supply a value to it, we will have to incorporate a search routine into the solution that searches down through the step file directories for one that has contains something in its file name. In this solution, I'm assuming this custom property already exists and already contains the needed path of the exported step files. Let me know if this is not the case.
I've created an iLogic rule you can try.
This rule is designed to be ran while the main assembly file is open and active
Here's the code:
Sub Main
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then
MsgBox("This rule was designed to run while an Assembly Document is active.",vbOKOnly, "WRONG DOCUMENT TYPE")
Exit Sub
End If
Dim oADoc As AssemblyDocument = ThisAssembly.Document
'open the drawing for this assembly - assuming it has same path and file name as model file (with different file extension)
Dim oDDoc As DrawingDocument = ThisApplication.Documents.Open(oADoc.FullFileName.Replace(".iam", ".dwg"))
'Get the PartsList - assuming it is the first PartsList found within the drawing document
Dim oPList As PartsList
For Each oSheet As Inventor.Sheet In oDDoc.Sheets
If oSheet.PartsLists.Count > 0 Then
oPList = oSheet.PartsLists.Item(1)
End If
Next
Dim oCol As Integer
For oCol = 1 To oPList.PartsListColumns.Count
If oPList.PartsListColumns.Item(oCol).Title = "Step File" Then ' <<<< CHECK THIS NAME >>>>
Exit For
End If
Next
Dim oRow As PartsListRow
For Each oRow In oPList.PartsListRows
SetStepFilePath(oRow, oCol)
Next
End Sub
Sub SetStepFilePath(ByRef oPLRow As PartsListRow, ByRef oPLCol As Integer)
'Dim oPartsList As PartsList = oPLRow.Parent
Dim oDrawingBOMRow As DrawingBOMRow = oPLRow.ReferencedRows.Item(1)
Dim oBOMRow As BOMRow = oDrawingBOMRow.BOMRow
Dim oRowDoc As Document = oBOMRow.ComponentDefinitions.Item(1).Document
Dim oPropSets As PropertySets = oRowDoc.PropertySets
'Dim oStockNum As String = oPropSets.Item("Design Tracking Properties").Item("Stock Number").Value
' If oStockNum = vbNullString Then
' MsgBox("The 'Stock Number' property was empty in the following document:" & vbCrLf & _
' oRowDoc.FullFileName, vbOKOnly, "Sock Number Missing")
' End If
'Check for the custom 'StepFile' property
Dim oStepFileProp As Inventor.Property
Try ' <<<<<< MAKE SURE THE PROPERTY NAME IS SPELLED CORRECTLY >>>>>>>
oStepFileProp = oPropSets.Item("Inventor User Defined Properties").Item("StepFile")
'oStepFileProp = oPropSets.Item("Inventor User Defined Properties").Item("Step File")
Catch
MsgBox("The custom property named could not be found in the following document:" & vbCrLf & _
oRowDoc.FullFileName, vbOKOnly, "Custom Property Not Found")
Exit Sub
End Try
Dim oStepFile As String = oStepFileProp.Value
oPLRow.Item(oPLCol).Value = oStepFile
End Sub
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click 'LIKE' 👍.
If you have time, please... Vote For My IDEAS :light_bulb:and Explore My CONTRIBUTIONS
Inventor 2020 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum
Wesley Crihfield
(Not an Autodesk Employee)
Ok, I have adjusted my parts with correct iproperties.
I have set the StepFile ipropertie in both correctly, my parts and csv file.
I have exported the step files to the location: Z: \ Uni_Link \ Import \ StepFiles \ 202020 STEP Files
Where 202020 is the name of the assy and STEP Files is an addition from the ilogic code.
The name of the assy, 202020, is also written to the iproperty 'Project'.
In the ilogic form the iproperty 'Project' is translated to Verkooporder.
This Project number will change everytime i make a new configuration and will be saved with a new project number.
The name of the step file is the IProperty 'Stock Number' which will be translated to Artikelnr.
The location with the step file name, Z: \ Uni_Link \ Import \ StepFiles \ 202020 STEP Files \ 15000.stp,
I need it in my parts list under the custom ipropertie StepFile.
I placed the location, Z: \ Uni_Link \ Import \ StepFiles, already in de ipropertie because that is always the same.
When I run the current code the dwg is opened but the iproperty is not completed with the file location and step file number.
I have created an custom ipropertie, StepFile.
I put the Iporperties i need into that ipropertie.
I also put in the file location who is always the same.
And there, i get the compleet line i need to export to my csv file.
Without using iLogic.
Great.
Can't find what you're looking for? Ask the community or share your knowledge.