Using drawings to pass iproperties from a source model to many different target models

Using drawings to pass iproperties from a source model to many different target models

swalton
Mentor Mentor
313 Views
5 Replies
Message 1 of 6

Using drawings to pass iproperties from a source model to many different target models

swalton
Mentor
Mentor

I'm working out how to automate part of our hydraulic hose documentation.  We are trying to share part number, description and revision iproperties between a straight hose assembly parent and several different 3d routed hose assemblies.   The goal is to have a drawing file showing the straight hose assembly for our fabricators and isometric views of each route.  For example I create a 36" overall length hose.  In the real world, I can use that same hose to connect both the base and rod ends of a cylinder to a manual valve.  If I use Tube and Pipe, I have to create a new 3d model of the hose from the base end to the valve and a 2nd model from the rod end of the valve. 

  

We use Vault Pro and enforce unique filenames.  We normally make the model filename = drawing filename = company part number.  We don't use Items.  We have some custom code that uses the Vault BOM data to generate our purchasing info, so we have to be careful how we create our Inventor BOMS.

 

We haven't moved to Inventor 2022, so model states aren't available yet.

 

I plan to start with a straight hose assembly model with 2 ends and a length of hose.  I will use this model as a source of purchasing info for our prototype builds.  Once the prototype build is complete, I will start up Tube and Pipe to create 3d routes to match the prototype.  I want the machine BOM to remain the same as I replace the straigh hose models with the routed ones.

 

My current plan is to use an Inventor drawing to show both the straight hose and the formed hoses.  I want to write some iLogic to pull iproperties from the straight hose model and push them into the various routed hose models.

 

Rough workflow:

  1. User creates an idw
  2. The first base view on the first sheet shows the straight hose model
  3. Projected views of the straight hose model are added as required
  4. Base views of each different 3d routed hose model are added
  5. iLogic is run by user
    1. Code reads the Description, Part Number and Revision iprops from the straight hose model
    2. Code writes those iprops to each of the formed hose models
  6. User saves the updates

 

My challenges so far:

How do I identify the straight hose model in the drawing file?

How do I pull the iprop values from that model?

Do I store the values in the drawing iprops, or just in temporary variables in the ilogic coder?

Once I have the iprop values, how do I write them to the formed models, but not try to overwrite the existing values in the straight hose?

Should I try to create a form that displays the iprops, allows the user to edit them, and writes the values to all models in the drawing?

 

Suggestions? 

Example Code? 

 

 

 

Steve Walton
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Inventor 2025
Vault Professional 2025
0 Likes
314 Views
5 Replies
Replies (5)
Message 2 of 6

JelteDeJong
Mentor
Mentor

You can try this:

 

    Public Sub Main()

        Dim doc As DrawingDocument = ThisDoc.Document
        Dim sheet As Sheet = doc.ActiveSheet
        Dim straightHoseView = sheet.DrawingViews.Item(1)

        Dim straightHoseDoc As Document = straightHoseView.ReferencedDocumentDescriptor.ReferencedDocument
        Dim partNumber As String = ReadProperty(straightHoseDoc, "Design Tracking Properties", "Part Number")

        Dim doneDocs As New List(Of String)
        doneDocs.Add(straightHoseDoc.FullFileName)
        For Each view As DrawingView In sheet.DrawingViews
            Dim refDoc As Document = View.ReferencedDocumentDescriptor.ReferencedDocument
            If (doneDocs.Contains(refDoc.FullFileName)) Then Continue For

            SetProperty(refDoc, "Design Tracking Properties", "Part Number", partNumber)
            doneDocs.Add(refDoc.FullFileName)
        Next
    End Sub

    Public Function ReadProperty(doc As Document, setName As String, name As String) As String
        Dim propSet = doc.PropertySets.Item(setName)
        Dim prop = propSet.Item(name)
        Return prop.Value
    End Function

    Public Sub SetProperty(doc As Document, setName As String, name As String, value As Object)
        Dim propSet = doc.PropertySets.Item(setName)
        Try
            Try
                Dim prop = propSet.Item(name)
                prop.Value = value
            Catch ex As Exception
                propSet.Add(value, name)
            End Try
        Catch ex As Exception
            MsgBox("Could not change/update document: " & doc.FullFileName)
        End Try
    End Sub

a list of all property set names and property names can be found here:

https://modthemachine.typepad.com/my_weblog/2010/02/accessing-iproperties.html (Almost in the end)

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 3 of 6

A.Acheson
Mentor
Mentor

 

How do I identify the straight hose model in the drawing file? 

This will depend on how you approach the documentation. You could read a part number or filename or in the code @JelteDeJong provided to ensure you place the straight pipe length as first view. The code does a good job of pushing all the iproperties to other views and there model files from within the drawing.

 

The only thing you might want to do is to check the hoses are actually the same length as your straight hose model which can be done in the model by checking the Bom manually or in the drawing by using code to check the unit qty. I noticed that when you copy hose assembly the in T&P the part number gets changed so you can either updated there or wait until the drawing stage and push back the data to the assy files. 

 

AAcheson_0-1640882616199.png

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 4 of 6

swalton
Mentor
Mentor

Thanks so much for the quick response.

 

The code works very well at pushing the part number from the source model to the target ones.

 

There is an unexpected issue with my plan.  I did not realize that Inventor routed hose assemblies have special save rules.  They must be saved from the pipe route assembly.  I can run the code in my drawings, but I can't safe the routed hose.  

 

I wonder if adding a save command to the ilogic will bypass the save restrictions.  

 

I will also try placing the hose run assembly in the drawing and see if I can get the save to work.

 

 

 

 

Steve Walton
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Inventor 2025
Vault Professional 2025
0 Likes
Message 5 of 6

A.Acheson
Mentor
Mentor

I got this to work by running the code in the drawing then open the parent assembly manually, this allows the child document to update. This seems to send a check for changes signal to all its childs and then it saves the part number change (existing in temporary memory to the child assembly. No flag of iProperty change shows up in the parent assembly so you will need to know the process to ensure it gets saved. Unfortunately you will not be able to get from the child assembly back to the parent to do the save by code so it will be a manual operation. 

 

AAcheson_0-1640891779416.png

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 6 of 6

swalton
Mentor
Mentor

I added an off-sheet view of the tube-and-pipe assembly.  That let me save the drawing and the modified hoses.

 

It will be interesting to see how this works with Vault.

 

swalton_0-1640892300330.png

 

 

Off to test more!

Steve Walton
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Inventor 2025
Vault Professional 2025
0 Likes