Blog posts
Bio
By Clint Brown
I was talking to a customer earlier in the week about their manufacturing process, and they manually add a Job number to every drawing of every component they manufacture, I decided to automate the process with a bit of iLogic.
Check out the video below, the code I used is at the bottom of this post.
'Rule 1 - Parameters:
'check for custom Parameter and add it if not found
Dim ParamName1 As String = "Comments"
Dim ParamName2 As String = "OldComment"
Dim ParamName3 As String = "JN"
customPropertySet = ThisApplication.ActiveDocument.ComponentDefinition.Parameters.UserParameters
Try
prop = customPropertySet.Item(ParamName1)
Prop = customPropertySet.Item(ParamName2)
Prop = customPropertySet.Item(ParamName3)
Catch
customPropertySet.AddByValue(ParamName1, "", UnitsTypeEnum.kTextUnits)
customPropertySet.AddByValue(ParamName2, "", UnitsTypeEnum.kTextUnits)
customPropertySet.AddByValue(ParamName3, "", UnitsTypeEnum.kTextUnits)
End Try
'Rule 2 - Jobs
'This Code by Clint Brown of Cadline with Code adapted from the following sources:
'http://inventortrenches.blogspot.co.uk/2011/05/use-ilogic-to-add-and-use-custom.html
'http://forums.autodesk.com/t5/Autodesk-Inventor/i-Logic-push-i-Properties/td-p/3820767
'Input boxes to capture Job Number and Amount of Parts being made
JN =InputBox("Specify Job Number", "Cadline Community", "0000")
RuleParametersOutput()
InventorVb.DocumentUpdate()
'Wait a moment before Continuing
System.Threading.Thread.CurrentThread.Sleep(50)
'Setting up the Comments Parameter
OldComment = Comments
RuleParametersOutput()
InventorVb.DocumentUpdate()
'Wait a moment before Continuing
System.Threading.Thread.CurrentThread.Sleep(50)
Comments = OldComment + vbLf + "Job Number: " + JN + " _____ Date: " + Datestring
'Making the Comments iProperty equal to the Comments Paramter
iProperties.Value("Summary", "Comments") = Comments
RuleParametersOutput()
InventorVb.DocumentUpdate()
'Wait a moment before Continuing
System.Threading.Thread.CurrentThread.Sleep(50)
'Push Parameters from Main Assembly to all components
Dim openDoc As Document
openDoc = ThisDoc.Document
Dim docFile As Document
For Each docFile In openDoc.AllReferencedDocuments
Dim FNamePos As Long
FNamePos = InStrRev(docFile.FullFileName, "\", -1)
Dim docFName As String
docFName = Right(docFile.FullFileName, Len(docFile.FullFileName) - FNamePos)
iProperties.Value(docFName, "Summary", "Comments") = iProperties.Value("Summary", "Comments")
Next
'Wait a moment before Continuing
System.Threading.Thread.CurrentThread.Sleep(50)
'MessageBox.Show("Job Complete", "Cadline Community")
Comments
0 comments
Please sign in to leave a comment.