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.
Solved! Go to Solution.
Solved by lkrenzler. Go to Solution.
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.
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.
Wow, this thread is a blast from the past.
Still one of my most heavily used iLogic rules.
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
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.
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.
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.
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.
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
FYI, here are a few existing ideas to vote for: