Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Any way to attach item numbers from parts list to drawing view labels?

50 REPLIES 50
SOLVED
Reply
Message 1 of 51
lkrenzler
5817 Views, 50 Replies

Any way to attach item numbers from parts list to drawing view labels?

Is there any way to attach the part number from the parts list to a drawing view?  I've attached a very simple example.  

 

Many parts I have need separate detail drawings.  The part obviously has an item number in the parts list which can change if items are added/sorted etc.

 

In the view label, I'd like to have the item number so that they can change with the parts list and stay attched to the drawing view.

 

Any ideas on how to do this?  Thanks for any help.

 

PLst.jpg

 

Num.jpg

----------------------------------------------------------------------------------

Inventor Pro 2019 - Win. 10 - GeForce GTX 1080 .
50 REPLIES 50
Message 41 of 51
mattsonfire
in reply to: salariua

Greetings!

I was trying to enter your "Item numbers on drawing view" code into ilogic and I will admit i am an absolute novice in iLogic and programming in general.

What parts of the code do I have to change to fit my filenames and such to make it work?

This is the error i get when i try to enter a new rule in my .iam model

"
Error in rule: Rule2, in document: OVEN FRAME WELDMENT.iam
Unable to cast COM object of type 'System.__ComObject' to interface type 'Inventor.DrawingDocument'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{29F0D467-C114-11D2-B77F-0060B0F159EF}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE))."

Or perhaps do you have a recommendation for a beginner tutorial in iLogic programming so I can get better understanding of the syntax?
Inventor 2013
Windows ME(amirite?)
Message 42 of 51
salariua
in reply to: mattsonfire

Hi Matt,

 

Here's a starting point for learning API.

 

http://usa.autodesk.com/adsk/servlet/index?id=1079044&siteID=123112

 

You need to run this code from the drawing (IDW or Inventor DWG) and not from the assembly.

 

Keep us posted.

 

 

 

Adrian S.
blog.ads-sol.com 

AIP2012-2020 i7 6700k AMD R9 370
Did you find this reply helpful ?
If so please use the Accepted Solutions or Like button - Thank you!
Message 43 of 51
RJR89
in reply to: lkrenzler

I honestly can't believe Autodesk havent added this function natively yet.....

 

Their are work arounds but it should really be included by default now.

Message 44 of 51
rhasell
in reply to: RJR89

Wow, this thread is a blast from the past.

 

Still one of my most heavily used iLogic rules.

 

Reg
2024.2
Please Accept as a solution / Kudos
Message 45 of 51
k.malek
in reply to: salariua

Hi,

 

I see that you are good in iLogic. 
I try to use this code but unfortunately after I start is displaying the error.

 

 

"Error in rule: Rule1, in document: Assembly2.idw

The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))"

 

I've found that the problem is in part of code:

 

                If StrComp(oModelFileName, oRowFileName, CompareMethod.Text)=0 Then
                    'Get the value of Item from the Parts List
                    'Row name needs to be case sensitive or use 1 for first 2 for second etc.
                    oCell  = oPartList.PartsListRows.Item(j).Item("Item") 'Row name needs to be case sensitive or use 1 for first 2 for second etc.
                    'get the value of text in cell
                    Dim oItemValue As String
                    oItemValue = oCell.Value
                   
                    'Show the view label
                    oView.ShowLabel = True
                    'format the text first line
                    oStringItem = "<StyleOverride Underline='True' FontSize='0.35'> ITEM " & oItemValue & " </StyleOverride>"
                    'format the text second line
                    oStringScale = "<Br/><StyleOverride FontSize='0.3'>(Scale <DrawingViewScale/>)</StyleOverride>"
                   
                    'add to the view label
                    oView.Label.FormattedText =  oStringItem & oStringScale
                End If 

 

Could you help me. What is the reason of it.

 

I use Inventor 2018.

 

Regards

Chris Malek

Message 46 of 51
cadman777
in reply to: lkrenzler

Hi lk,

 

I bypassed this problem many years ago by assigning the native Inventor 'STOCK NUMBER' as the 'MARK #' in all my parts/drawings. That way you can use a simple iProperty in your drawing view template in the Styles Manager to get the MARK # into the drawing view label.

 

The only downside to this is the time you spend making sure all the individual MARK #'s are different. But that's no big deal if you setup your BOM correctly. I use the BOM as a spreadsheet to check EVERYTHING in my model. I have every single OAL dimension and piece of relevant data in the BOM. So it's very easy to use to CHECK my final release of a project. I don't mind, b/c it takes only a few hours on very large models (1000+ discrete parts). And whenever you make changes to the model, the changes automatically update in the drawings (view label, parts list, title block, etc.)

 

The other up-side to this method is you can make compound MARK #'s, like I do to differentiate between all kinds of assemblies, such as GA's, mechanical, piping, structural, weldments, hydraulic, etc. The way I do that is make the iam (assembly) file template have a compound MARK # (whereas the single part ipt template has a simple MARK #). All that requires one extra column in your BOM. You include that extra column in your iam assembly file template.

 

I found that the more detailed I make my templates (= separate each Custom iProperty from the others), the more control I have over my Numbering. I found that NUMBERING IS EVERYTHING in a project. For example: I've had customers complain about how the Tekla guys draw tanks and other non-structural equipment. So they would give me the work instead, simple b/c the Tekla NUMBERING is very difficult to read. So is the Tekla hierarchy of the 3d model (sub-assemblies, and sub-sub-assemblies, etc.), as seen on the drgs. So they give me the work b/c my drawings are readable compared to the structural garbage that the Tekla guys create, which doesn't at all fit the mechanical CAD world.

 

Anyways, that's my 2 cent's worth.
I realize this is an old post, but I got pinged today b/c someone posted to it.

So I figured I give some of the newbies a different viewpoint to consider.

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
Message 47 of 51
cameron.houston
in reply to: lkrenzler

I searched everywhere to try and get this done and ultimately I ended up having to code a button to do this so I thought I would share so other people can use. The button goes through all drawing views in a drawing and compares them back to the BOM to find what ITEM number the part is. It then adds that item number to the drawing view label.  See below.

code1.png 

 

I used Brian Ekins nifftyinventoraddin template to do so. I have attached a compressed zip folder with the entire Visual Studio SLN as well as everything else needed to just drag and drop into the inventor add in location on the local drive.

 

 

Here is what the source code looks like.

 

' TODO: This module exists as a convenient location for the code that does the real
'       work when a command is executed.  If you're converting VBA macros into add-in
'       commands you can copy the macros here, make changes to make them VB.NET compatible,
'       and change any references to "ThisApplication" to "g_inventorApplication".  The example
'       command in StandardAddInServer.vb demonstrates running the "SampleCommandFunction" below.
Imports Inventor

Public Module CommandFunctions
    ' Example function that's called when the sample command is executed.
    Public Sub SampleCommandFunction()
        'define active document as the current drawing doc. Will produce an error if its not a drawing doc
        Dim oDrawDoc As DrawingDocument
        oDrawDoc = g_inventorApplication.ActiveDocument
        'Set sheet to be active sheet in window
        Dim oSheet As Sheet
        oSheet = oDrawDoc.ActiveSheet
        'Get the Primary Parts List via user mouse click
        Dim oActPartList As PartsList
        oActPartList = g_inventorApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingPartsListFilter, "Select the parts list to begin")
        'Get the drawing number by extracting it from the referenced assemblies display name
        Dim oRefAssembly As String
        oRefAssembly = oActPartList.ReferencedFile.DisplayName
        Dim oRefAssemblyCount As Integer
        oRefAssemblyCount = Len(oRefAssembly)
        'This removes the eight characters at the end of all referenced assemblies .000.iam
        Dim RMV As Integer
        RMV = 8
        'Get Drawing Number
        Dim LengthReq As Integer
        LengthReq = (oRefAssemblyCount - RMV)
        'Debug.Print "The length to the right of the dot is" & LengthReq
        'MsgBox ("The Length to the right of the dot is" + CStr(LengthReq))
        Dim oDWGNum As String
        oDWGNum = Left(oRefAssembly, LengthReq)
        'MsgBox ("The Drawing Number is" + oDWGNum)
        'Manually Get Drawing Number
        'Dim oDWG As Variant
        'oDWG = InputBox("What is the number for this Drawing?")
        'Loop through MPN numbers and compare MPN value to value of drawing, if they match get item number, if not skip
        For i = 1 To oActPartList.PartsListRows.Count
            Dim oMPNCheck As String
            oMPNCheck = oActPartList.PartsListRows.Item(i).Item(2).Value
            Dim oMPNCheckLeft As String
            oMPNCheckLeft = Left(oMPNCheck, LengthReq)
            If oMPNCheckLeft = oDWGNum Then
                Dim oTest As String
                oTest = Right(oMPNCheck, 3)
                oActPartList.PartsListRows.Item(i).Item(1).Value = oTest
            Else
            End If
        Next
    End Sub

End Module
 
 
FYI some specific quirks I added was not having the item number appear for the main assembly (because obviously its not referenced in the BOM) and not having the item number appear for section or detail views.
Message 48 of 51
cadman777
in reply to: lkrenzler

Thanx for doing this for us.

I may try it, even though I have a Custom iProperty for the BOM Item Number.

If it works for on my old install of Inventor, maybe I can find another use for it.

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
Message 49 of 51
cameron.houston
in reply to: cadman777

oops my mistake I copied the code for one of my other buttons.  Here is the right code. For reference the other button changes the item number to the last 3 digits of the part number. This is a company specific request.

 

 

Here is the right code:

 

Public Sub SampleCommandFunction()
'Get the active document which must be a drawing or else it will error
Dim oDrawDoc As DrawingDocument
oDrawDoc = g_inventorApplication.ActiveDocument

'Create an object to store all the sheets called "oSheets"
Dim oSheets As Sheets
oSheets = oDrawDoc.Sheets

'Create an object to store an individual sheet
Dim oSheet As Sheet

'For every sheet in drawing doc
For Each oSheet In oSheets

'Create an object to store all the drawing views
Dim oViews As DrawingViews
oViews = oSheet.DrawingViews

'Create an object to store an individual view
Dim oView As DrawingView

'For ever drawing view on the sheet
For Each oView In oViews

Dim c As Integer
c = 0
'Get the part number associated with the drawing view
Dim oPartNumber As String
oPartNumber = oView.ReferencedDocumentDescriptor.ReferencedDocument.PropertySets.Item(3).Item(2).Value

'Testing Message Box
'MsgBox ("Drawing View " + oPartNumber)

'Create an object to store all the boms
Dim oBoms As DrawingBOMs
oBoms = oDrawDoc.DrawingBOMs

'Create an object to store an individual bom
Dim oBom As DrawingBOM

'For every bom in the drawing
For Each oBom In oBoms


'Locate where the MPN & Item Columns Are
'Loop through all the BOM headers to find the columns and then save the column number they are in
Dim oMPNCol As Integer

For i = 1 To oBom.DrawingBOMColumns.Count

Dim oFindMPN As String
oFindMPN = oBom.DrawingBOMColumns.Item(i).Title

If oFindMPN = "MPN" Then
oMPNCol = i
End If
Next

Dim oFindItemNumCol As Integer

For i = 1 To oBom.DrawingBOMColumns.Count
Dim oFindItemNum As String
oFindItemNum = oBom.DrawingBOMColumns.Item(i).Title

If oFindItemNum = "ITEM" Then

oFindItemNumCol = i
End If
Next

 

'Store Bom reference assembly
Dim RefAssemblyLong As String
RefAssemblyLong = oBom.ReferencedDocumentDescriptor.DisplayName

'Count how many characters in RefAssembly
Dim oLengthAssembly As Integer
oLengthAssembly = Len(RefAssemblyLong)

'Assembly name without .iam (4 characters)

Dim RefAssembly As String
RefAssembly = Left(RefAssemblyLong, oLengthAssembly - 4)

'For every row in the BOM
For i = 1 To oBom.DrawingBOMRows.Count

'Get the MPN number for the Bom Item
Dim oMPN As String

oMPN = oBom.DrawingBOMRows.Item(i).Item(oMPNCol).Value

Dim oItem As String
oItem = oBom.DrawingBOMRows.Item(i).Item(oFindItemNumCol).Value

If oView.ViewType <> DrawingViewTypeEnum.kDetailDrawingViewType And oPartNumber = oMPN Then
oView.Label.FormattedText = ("DETAIL ITEM " & oItem & vbCrLf & "MPN NUMBER " & oPartNumber)
End If

Next

Next

Next
Next

MsgBox("Detail Views Have Been Updated With Item Number")
End Sub

 

 

Message 50 of 51
RJR89
in reply to: lkrenzler

any sign of this functionality being natively added to inventor yet?

Message 51 of 51
SER4
in reply to: lkrenzler

FYI, here are a few existing ideas to vote for:

https://forums.autodesk.com/t5/inventor-ideas/link-parts-list-item-number-to-notes-views-and-labels/...

https://forums.autodesk.com/t5/inventor-ideas/part-detail-view-labeled-with-it-s-item-number-in-bom/...

 

Dell Precision 5680 Laptop; Win11 Pro; 64GB RAM; i9-13900H CPU; Intel Iris Xe Graphics, NVIDIA RTX 3500 Ada Laptop GPU.
Vault Pro 2023.4.1 (28.4.20.0); Inventor Pro 2023.4.1 (418).

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report