• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk Inventor Customization

    Reply
    Employee
    Posts: 932
    Registered: ‎02-24-2009

    Re: iLogic Variable Transfer

    02-21-2011 10:07 AM in reply to: OkieWolf

    You're placing the pipes as Custom parts, right?  That way you can specify any length you want.  The content center replacement function code will only work on Standard parts.  I'll see if if can be modified to work on Custom parts as well.

     

     Note that you can replace Custom parts using the iLogic Component.Replace function.  But to use that, you must first generate the exact part you need from the content center.  The part must be available in your workspace or local library so that Component.Replace can find it.

     



    Mike Deck
    Software Developer
    DLS - Mechanical Design
    Autodesk, Inc.

    Please use plain text.
    Active Contributor
    OkieWolf
    Posts: 27
    Registered: ‎10-28-2010

    Re: iLogic Variable Transfer

    02-21-2011 10:10 AM in reply to: MjDeck

    So, if I'm understanding you, the part has to be placed first then the length parameter adjusted to what it needs to be....correct?

    Please use plain text.
    Employee
    Posts: 932
    Registered: ‎02-24-2009

    Re: iLogic Variable Transfer

    02-21-2011 10:44 AM in reply to: MjDeck

    If you are placing the pipe as a Custom part, then the ContentCenterReplace code will not work.  I am looking at changing it.

     

    But as a workaround, you can use Component.Replace.  To make that work, first place the pipe in one size and length that you require.  Then (maybe in a temporary assembly in the same folder), place other sizes and lengths that you need.  Now that you've placed them, the part files are available to be used by Component.Replace.  I don't know if you will find this workaround to be useful.  How many different sizes and lengths of a particular pipe component do you require in your design?

     



    Mike Deck
    Software Developer
    DLS - Mechanical Design
    Autodesk, Inc.

    Please use plain text.
    Active Contributor
    OkieWolf
    Posts: 27
    Registered: ‎10-28-2010

    Re: iLogic Variable Transfer

    02-21-2011 10:57 AM in reply to: MjDeck

    The pipe sizes can be ANY normal pipe size.

    However, I found another workaround. You CAN use your Replacer to swap out the pipes by calling it in as the Content Center built in length. Then change the length parameter of the pipe to make it the correct length. After that you can use MakePath to rename it to the correct name with the new length.

    In this case, it will take only four lines of code.

     

    replacer.Replace(pPartName, PfamilyName, pNewName)
    pNewPartName = pNewName & ":1"
    Parameter(pNewPartName, "PL") = OldPlength

     

    I only show three here because I haven't done the MakePath yet.

    Please use plain text.
    Active Contributor
    OkieWolf
    Posts: 27
    Registered: ‎10-28-2010

    Re: iLogic Variable Transfer

    02-21-2011 12:48 PM in reply to: OkieWolf

    I take that back. You can't rename a part with MakePath.

    Please use plain text.
    Active Contributor
    OkieWolf
    Posts: 27
    Registered: ‎10-28-2010

    Re: iLogic Variable Transfer

    02-22-2011 12:27 PM in reply to: OkieWolf

    Hey Mike, here is another question. Our Content Center is custom and has a custom name. Today I put our custom Content Center on my machine and turned all others off. Now Replacer can't find things.

     

    Is Replacer specific to out-of-the-box Content Center and not able to see our custom one?

    Please use plain text.
    Active Contributor
    OkieWolf
    Posts: 27
    Registered: ‎10-28-2010

    Re: iLogic Variable Transfer

    02-22-2011 12:34 PM in reply to: OkieWolf

    I think I may have found the problem with the custom Content Center so disregard that last question. The problem was with my code........imagine that  :smileytongue:

    Please use plain text.
    Active Contributor
    OkieWolf
    Posts: 27
    Registered: ‎10-28-2010

    Re: iLogic Variable Transfer

    02-22-2011 01:09 PM in reply to: OkieWolf

    Ok, I fixed my code. But, yesterday when it swapped out the pipes I could still go in and adjust the length using the "Parameter" command on the newly inserted pipe and make it the correct length. Today I can't. Yesterday it changed the diameter in the name but not the length. Today, with the custom Content Center, it isn't changing either one, even though the parameter name is still the same from yesterday to today.

     

    I'm fairly baffled at the moment.

     

    Any insight would be greatly appreciated.

    Please use plain text.
    Employee
    Posts: 932
    Registered: ‎02-24-2009

    Re: iLogic Variable Transfer

    02-23-2011 09:55 AM in reply to: MjDeck

    Using a rule to change the length after replacing the part probably isn't equivalent to selecting a different part and custom length in the Content Center UI.  I'm going to see if I can improve the rule function to accept a custom length or other parameter.

     But I can also look at the method you're using.  Can you post the rule you're using?  I should be able to create a test assembky to try it out.

     



    Mike Deck
    Software Developer
    DLS - Mechanical Design
    Autodesk, Inc.

    Please use plain text.
    Active Contributor
    OkieWolf
    Posts: 27
    Registered: ‎10-28-2010

    Re: iLogic Variable Transfer

    02-23-2011 10:29 AM in reply to: MjDeck

    AddReference "NozzleAdjuster1"

    Sub Main
    AddVbFile ("ContentCenterReplace.iLogicVb")
    Dim app As Inventor.Application = ThisApplication
    Dim oDoc As Inventor.AssemblyDocument = app.ActiveDocument
    Dim oCompDef As Inventor.ComponentDefinition = oDoc.ComponentDefinition
    Dim oCompOcc As Inventor.ComponentOccurrence

    For Each oCompOcc In oCompDef.Occurrences
        Dim compDef as Inventor.ComponentDefinition = oCompOcc.Definition
        Dim compDoc as Inventor.Document = compDef.Document
        Dim PartName As String = System.IO.Path.GetFileNameWithoutExtension(compDoc.FullFileName)
        IsPipe = Left(PartName, 4)
            If IsPipe = "Pipe" Then
            CurrentSize = Mid(PartName, 6, 2)
            SizeChk = Mid(CurrentSize, 2, 1)
            pNewNameLength = PartName.Length
            pNewNameRemainL = pNewNameLength - 7
            pNewNameRemain = Mid(PartName, 8, pNewNameRemainL)
            pPartName = PartName & ":1"
            OldPlength = Parameter(pPartName, "PL")
            PipeWall = Parameter(pPartName, "t")
            PipeFlangeOffset = Parameter(oDoc, "d0")
            CurrentNozzleProjection = Parameter(oDoc, "d4")
                If SizeChk = "" Or SizeChk = " " Or SizeChk = nil Then
                CurrentSize = Mid(PartName, 6, 1)
                pNewNameRemainL = pNewNameLength - 6
                pNewNameRemain = Mid(PartName, 7, pNewNameRemainL)
                pNewName = IsPipe & CurrentSize & pNewNameRemain
                End If

            End If
    Next

    Dim dlg as New ClassLibrary1.Dialog1
    dlg.NozzleSize = NozzleSize
    dlg.CurrentSize = CurrentSize
    dlg.PipeWall = PipeWall
    dlg.PipeFlangeOffset = PipeFlangeOffset
    dlg.CurrentNozzleProjection = CurrentNozzleProjection
    dlg.NewNozzleProjection = NewNozzleProjection
    i = dlg.ShowDialog()
        
    For Each oCompOcc In oCompDef.Occurrences

    Dim compDef as Inventor.ComponentDefinition = oCompOcc.Definition
    Dim compDoc as Inventor.Document = compDef.Document
    Dim PartName As String = System.IO.Path.GetFileNameWithoutExtension(compDoc.FullFileName)
    Dim replacer As New ContentCenterReplace(ThisDoc.Document, ThisApplication, "en-US")
    Dim PfamilyName As String = "Tube & Pipe:Conduits:smileytongue:ipes:ASTM A 53/A 53M Pipe"
    pCCFam = "ASTM A 53/A 53M "
    Dim FfamilyName As String = "Tube & Pipe:Fittings:Flanges:ASME B16.5 Flange Slip-On Welding - Class 150"

    If IsFlange <> "ASME B16.5 Flange Slip-On Welding - Class 150" Then
    IsPipe = Left(PartName, 4)
    End If
    If IsPipe <> "Pipe" Then
    IsFlange = Left(PartName, 45)
    End If

    If(i = vbOK)Then
    NozzleSize = dlg.NozzleSize
    PipeFlangeOffset = dlg.PipeFlangeOffset
    NewNozzleProjection = dlg.NewNozzleProjection
        If NozzleSize <> "" And NozzleSize <> " " And NozzleSize <> nil Then
            If IsPipe = "Pipe" Then
                pNewName = IsPipe & " " & NozzleSize & " - XS - .001"
                replacer.Replace(pPartName, PfamilyName, pNewName)
                pNewPipeName = pNewName & ":1"
                ThisDoc.Document.ComponentDefinition.Occurrences.Item(1).Name = pNewPipeName
                Parameter(pNewPipeName, "PL") = OldPlength
            End If

            If IsFlange = "ASME B16.5 Flange Slip-On Welding - Class 150" Then
                fPartName = PartName & ":1"
                NewFlange = IsFlange & " " & NozzleSize
                replacer.Replace(fPartName, FfamilyName, NewFlange)
            End If
        End If
        
        If PipeFlangeOffset <> "" And PipeFlangeOffset <> " " And PipeFlangeOffset <> nil Then
            Parameter(oDoc, "d0") = PipeFlangeOffset
        End If
        
        If NewNozzleProjection <> "" And NewNozzleProjection <> " " And NewNozzleProjection <> nil Then
            Parameter(oDoc, "d4") = NewNozzleProjection
        End If
        
    End If

    Next
        
    UpdateNozzle
    End Sub

    Sub UpdateNozzle
    InventorVb.DocumentUpdate
    InventorVb.SetViewCamera(ViewCameraOption.FitExtents, New Double() {-121.30039731877672, 145.50927339213723, 145.44114957469338}, New Double() {24.208876073360443, 0, -0.068123817443847656}, New Double() {0.40824829046386318, 0.81649658092772592, -0.40824829046386313}, New Double() {76.824887490943567, 87.260303212016993})
    IsFlange = nil
    IsPipe = nil
    PartName = nil
    CurrentNozzleProjection = nil
    NewNozzleProjection = nil
    PipeFlangeOffset = nil
    End Sub

     

     

    I figured out if I use

    ThisDoc.Document.ComponentDefinition.Occurrences.Item(1).Name = pNewPipeName

    I can rename the pipe and continue on.


    You will need a pipe and a 150# raised face slip on flange parts put together in an assembly.

    You will also need to create a dialog in Dot Net and build as a DLL. The Dot Net code is as follows :

     

    Public Class Dialog1
        Public NozzleSize As String
        Public CurrentSize As String
        Public PipeFlangeOffset As String
        Public PipeWall As String
        Public CurrentNozzleProjection As String
        Public NewNozzleProjection As String

        Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
            NozzleSize = TextBox1.Text
            PipeFlangeOffset = TextBox2.Text
            NewNozzleProjection = TextBox3.Text
            Me.DialogResult = System.Windows.Forms.DialogResult.OK
            Me.Close()
        End Sub

        Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
            Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
            Me.Close()
        End Sub

        Private Sub Dialog1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
            Label2.Text = "Current Nozzle Size = " & CurrentSize
            Label5.Text = "Current Pipe/Flange Offset = " & PipeFlangeOffset
            Label6.Text = "Current Pipe Wall Thickness = " & PipeWall
            Label8.Text = "Current Nozzle Projection = " & CurrentNozzleProjection
            TextBox1.Focus()
            TextBox1.SelectAll()
        End Sub

        Private Sub Dialog1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Label2.Text = "Current Nozzle Size = " & CurrentSize
            Label5.Text = "Current Pipe/Flange Offset = " & PipeFlangeOffset
            Label6.Text = "Current Pipe Wall Thickness = " & PipeWall
            Label8.Text = "Current Nozzle Projection = " & CurrentNozzleProjection
            TextBox1.Focus()
            TextBox1.SelectAll()
        End Sub

    End Class

     

    Please use plain text.