Happiness is...
I received the call yesterday to say that we have been granted a permanent residency Visa for Australia.
I am still in shock, as we have been waiting so long now, finally the axe over our heads has been removed and we can now start our lives again.
☺ ☺ ☺ ☺
Thursday, 17 July 2014
Wednesday, 9 July 2014
iLogic Code to create Cusom Parameters
This little piece of code was created to bulk create custom parameters.
When I start with a new project, I sometimes need to create a lot of parameters in the skeleton part/s. This can sometimes be rather time consuming, so I wrote this snippet.
When I start with a new project, I sometimes need to create a lot of parameters in the skeleton part/s. This can sometimes be rather time consuming, so I wrote this snippet.
'GDI iLogic to create a new User Parameter
Sub Main()
Dim oNewParam as String
Dim oPartDoc as PartDocument = ThisDoc.Document
'Get the new Parameter Name
tNewParam = InputBox("Input Name for New Parameter" & vbNewLine & "" & vbNewLine & "add '-DEG' for Angle" & vbNewLine & "E.G: xxx-DEG", "GDI - iLogic", "") ' prompt the user for a parameter name
If tNewParam <>"" Then 'Error Check if user presses the Cancel key
'Split the name If Needed
oNewParam = Split(tNewParam, "-") (0)
'Check for the new parameter name
'If found then Exit to the question of create something else.
Try
oParam = oPartDoc.ComponentDefinition.Parameters(oNewParam)
i1 = MessageBox.Show(oNewParam & vbNewLine & "Parameter already exists", "GDI - iLogic", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1)
Call AsktoCreateAnother ' Subroutine to create another
Catch 'If the parameter was not found, then create a new one.
If tNewParam.contains ("deg") Or tNewParam.contains ("DEG")Then 'Checks the Temp name, inputted by user
Call DegreeSUB (oNewParam) 'Pass the Variable name to the sub
Else
Call mmSUB (oNewParam) 'Pass the Variable name to the sub
'Return
End If
End Try
Else 'this one comes from the cancel key press
MessageBox.Show("Cancel key pressed", "GDI - iLogic")
Return 'exit the code if Cancel is pressed.
End If
End Sub
Sub DegreeSUB (ByRef oNewParam as String)
Dim oPartDoc as PartDocument = ThisDoc.Document
Dim userParams As UserParameters = oPartDoc.ComponentDefinition.Parameters.UserParameters
oValue=InputBox("Add a Value?", "GDI - iLogic", 0) ' Get a Value if desired
oComment=InputBox("Add a description if desired?", "GDI - iLogic", "") ' Get a description if desired
Dim newParam As UserParameter ' Placeholder
Dim oFormat As CustomPropertyFormat
newParam = userParams.AddByExpression(oNewParam, oValue, "deg") ' Create the Parameter as per above
newParam.ExposedAsProperty=True 'Flag for Export
oFormat=newParam.CustomPropertyFormat 'For some reason or other this line is needed to enable the following formatting
oFormat.PropertyType=Inventor.CustomPropertyTypeEnum.kTextPropertyType
oFormat.Precision=Inventor.CustomPropertyPrecisionEnum.koneDecimalPlacePrecision 'Set one decimal place
'oFormat.Units="mm" 'Units
oFormat.ShowUnitsString=False
oFormat.ShowLeadingZeros=False
oFormat.ShowTrailingZeros=False
newParam.comment=oComment 'Set the Description
Call AsktoCreateAnother (oNewParam, oComment) ' Subroutine to add another
End Sub
Sub mmSUB (ByRef oNewParam as String)
Dim oPartDoc as PartDocument = ThisDoc.Document
Dim userParams As UserParameters = oPartDoc.ComponentDefinition.Parameters.UserParameters
oValue=InputBox("Add a Value?", "GDI - iLogic", 0) ' Get a Value if desired
oComment=InputBox("Add a description if desired?", "GDI - iLogic", "") ' Get a description if desired
Dim newParam As UserParameter ' Placeholder
Dim oFormat As CustomPropertyFormat
newParam = userParams.AddByExpression(oNewParam, oValue, "mm") ' Create the Parameter as per above
newParam.ExposedAsProperty=True 'Flag for Export
oFormat=newParam.CustomPropertyFormat 'For some reason or other this line is needed to enable the following formatting
oFormat.PropertyType=Inventor.CustomPropertyTypeEnum.kTextPropertyType
oFormat.Precision=Inventor.CustomPropertyPrecisionEnum.koneDecimalPlacePrecision 'Set one decimal place
'oFormat.Units="mm" 'Units
oFormat.ShowUnitsString=False
oFormat.ShowLeadingZeros=False
oFormat.ShowTrailingZeros=False
newParam.comment=oComment 'Set the Description
Call AsktoCreateAnother (oNewParam, oComment) ' Subroutine to add another
End Sub
Sub AsktoCreateAnother (ByRef oNewParam as String, ByRef oComment As String)
i2 = MessageBox.Show(oNewparam & " (" & oComment & ")" & " - Created" & vbNewLine & "Add Another", "GDI - iLogic", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1)
If i2 = "6" Then
Main 'Got to the begining
ElseIf i2 = "7" Then
'Return
End If
Return
End Sub
Sub DONEAsktoCreateAnother
i3 = MessageBox.Show("Add Another", "GDI - iLogic", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1)
If i3 = "6" Then
Main 'Got to the beginning
ElseIf i3 = "7" Then
'Return
End If
Return
End Sub
Wednesday, 2 July 2014
iLogic - Transfer a variable to a Sub routine
I discovered this one today, as I wanted a nice clean script, but I just could not pass a variable between my Sub Routines within iLogic.
I am pretty pleased with this, and will now try and make use of in other scripts.
Sub Main()
Dim oNewParam as String
Blah blah ... stuff in the script
Call NextSubRoutine (oNewParam) 'This is the important stuff - The bit in the brackets.
End Sub
Sub NextSubRoutine (ByRef oNewParam as String) 'NOTE: The bit in the brackets.
MessageBox.Show(oNewParam, "Variable transferred from the Main Sub")
blah blah ... stuff in the script
End Sub
I am pretty pleased with this, and will now try and make use of in other scripts.
Sub Main()
Dim oNewParam as String
Blah blah ... stuff in the script
Call NextSubRoutine (oNewParam) 'This is the important stuff - The bit in the brackets.
End Sub
Sub NextSubRoutine (ByRef oNewParam as String) 'NOTE: The bit in the brackets.
MessageBox.Show(oNewParam, "Variable transferred from the Main Sub")
blah blah ... stuff in the script
End Sub
Subscribe to:
Posts (Atom)