Thursday 17 July 2014

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.

☺ ☺ ☺ ☺

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.

'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

Friday 30 May 2014

Place Two Different Parts Lists on one Drawing

A question was raised on the Autodesk forum the other day on how to place the two different types of "Parts List" on one drawing

I thought I would make a quick video of the process.

Link to the original post:

http://forums.autodesk.com/t5/Inventor-General/Parts-list-BOM-views/m-p/4984744#M506048

Hope this helps :-)


Lines in the view are stretched after conversion to AutoCAD DWG

Lines in the view are stretched after conversion to AutoCAD DWG

This is something that comes up after every release of Inventor  and I thought I would post the link to the fix here:

http://beinginventive.typepad.com/being-inventive/2013/01/lines-in-the-view-are-stretched-after-conversion-to-autocad-dwg.html

The biggest issue is the spline creation.

  •  Edit the  .INI file created for exporting the Inventor files to AutoCAD I have a customized file as well as a customized Template.
  •  Find the line "REPLACE SPLINE=No", change the No with Yes and save the file

 My Customized ini file:


[EXPORT SELECT OPTIONS]
AUTOCAD VERSION=AutoCAD 2010
CREATE AUTOCAD MECHANICAL=No
USE TRANSMITTAL=No
USE CUSTOMIZE=No
CUSTOMIZE FILE=C:\Users\Public\Documents\Autodesk\Inventor 2012\Design Data\DWG-DXF\FlatPattern.xml
CREATE LAYER GROUP=No
PARTS ONLY=No
REPLACE SPLINE=Yes
CHORD TOLERANCE=0.001000
[EXPORT PROPERTIES]
SELECTED PROPERTIES=
[EXPORT DESTINATION]
SPACE=Model
SCALING=Text
ALL SHEETS=Yes
MAPPING=MapsBest
MODEL GEOMETRY ONLY=No
EXPLODE DIMENSIONS=No
SYMBOLS ARE BLOCKED=Yes
AUTOCAD TEMPLATE=C:\DATA\TEMPLATES\Standard.dwg
DESTINATION DXF=No
USE ACI FOR ENTITIES AND LAYERS=Yes
[EXPORT LINE TYPE & LINE SCALE]
LINE TYPE FILE=C:\Users\Public\Documents\Autodesk\Inventor 2012\COMPATIBILITY\Support\invISO.lin
Continuous=Continuous;0.
Dashed=DASHED;0.
Dashed Space=DASHED_SPACE;0.
Long Dash Dotted=LONG_DASH_DOTTED;0.
Long Dash Double Dot=LONG_DASH_DOUBLE_DOT;0.
Long Dash Triple Dot=LONG_DASH_TRIPLE_DOT;0.
Dotted=DOTTED;0.
Chain=CHAIN;0.
Double Dash Chain=DOUBLE_DASH_CHAIN;0.
Dash Double Dot=DASH_DOUBLE_DOT;0.
Dash Dot=DASH_DOT;0.
Double Dash Dot=DOUBLE_DASH_DOT;0.
Double Dash Double Dot=DOUBLE_DASH_DOUBLE_DOT;0.
Dash Triple Dot=DASH_TRIPLE_DOT;0.
Double Dash Triple Dot=DOUBLE_DASH_TRIPLE_DOT;0.