Hi
I am after help to change some code that was supplied by Curtis Waguespack that adds description to all parts with a certain type of material,(ie finds all material that is plywood and adds a description formula to the parts within an assembly)
what i am after is a input box to change all part thicknesses of all parts that are found to new user value
User value that we use to hold thickness values in all .ipts is G_T
below is code used to alter descriptions on all .ipts found with material = to (plywood)
''kUnknownDocumentObject = 12289
'kPartDocumentObject = 12290
'kAssemblyDocumentObject = 12291
'kDrawingDocumentObject = 12292
'kPresentationDocumentObject = 12293
'kDesignElementDocumentObject = 12294
'kForeignModelDocumentObject = 12295
'kSATFileDocumentObject = 12296
'kNoDocument = 12297
Dim openDoc As Document
openDoc = ThisDoc.Document
Dim mywidth As Integer
Dim docFile As Document
If openDoc.DocumentType = 12291 Then
For Each docFile In openDoc.AllReferencedDocuments
If docFile.DocumentType = 12290 Then
Dim FNamePos As Long
FNamePos = InStrRev(docFile.FullFileName, "\", -1)
Dim docFName As String
docFName = Right(docFile.FullFileName, Len(docFile.FullFileName) - FNamePos)
'select for part files with specified material
If iProperties.Material(docFName) = "PLYWOOD" Then
'set description
iProperties.Value(docFName, "Project", "Description")= "=<Material> <G_L>"
iProperties.Value(docFName, "Project", "Part Number") = Left(docFName, InStrRev(docFName, ".") - 1)
End If
End If
Next
Else
MessageBox.Show("You must have a valid Assembly document open before using this code!", "File Type Mismatch!")
End If
Solved! Go to Solution.
Solved by Curtis_Waguespack. Go to Solution.
Hi dclunie,
Here is some code that will set the Thickness parameter (if it is present) in each part file. You can use it as an example to modify your code.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Dim openDoc As Document openDoc = ThisDoc.Document Dim docFile As Document 'get input from user myThickness = InputBox("Enter Thickness", "iLogic", "0.75") 'look at all of the parts in the assembly For Each docFile In openDoc.AllReferencedDocuments If docFile.DocumentType = 12290 Then 'get the part file names Dim FNamePos As Long FNamePos = InStrRev(docFile.FullFileName, "\", -1) Dim docFName As String docFName = Right(docFile.FullFileName, Len(docFile.FullFileName) - FNamePos) 'select for part files with specified material if iProperties.Material(docFName) = "PLYWOOD" Then 'set description iProperties.Value(docFName, "Project", "Description")= "=<Material> <G_L>" iProperties.Value(docFName, "Project", "Part Number") = Left(docFName, InStrRev(docFName, ".") - 1) 'ignore error if parameter is not in the part Parameter.Quiet=True 'set parameter value Parameter(docFName, "Thickness") = myThickness End If End If Next iLogicVb.UpdateWhenDone = True
HI Curtis
Excellent piece of work you just saved me hours of manual work
Many Thanks
Dave
I was under the impression that cc / ifeatures used, for eg:
100x10 Flat Bar x 500 Lg
would have:
G_W = 100
G_H = 10
G_L = 500
I was planning on using these parram names for ease of coord with existing Inventor Nomenclature
If im mistaken could you enlighten me a bit further on what parts of inventor use what parrams
Cheers