Hide units in Part list

Hide units in Part list

eladm
Collaborator Collaborator
1,005 Views
15 Replies
Message 1 of 16

Hide units in Part list

eladm
Collaborator
Collaborator

Hi

 

I create a tube and pipes assembly in the drawing the part list is have mixed units :

 

eladm_0-1708855594364.png

 

Can I get a rule that delete/hide the units string ? it don't need to convert the value

regards

0 Likes
Accepted solutions (1)
1,006 Views
15 Replies
Replies (15)
Message 2 of 16

Andrii_Humeniuk
Advisor
Advisor

Hi @eladm . Not sure I understand exactly what you need. If you need to hide children rows (1.1, 1.2 ...) then use this code:

Dim oDDoc As DrawingDocument = TryCast(ThisDoc.Document, DrawingDocument)
If oDDoc Is Nothing Then Exit Sub
If oDDoc.ActiveSheet.PartsLists.Count = 0 Then Exit Sub
Dim oPList As PartsList = oDDoc.ActiveSheet.PartsLists(1)
For Each oRow As PartsListRow In oPList.PartsListRows
	Try : oRow.Expanded = False : Catch : End Try
Next

 If you need to hide rows that have children rows (1, 2, 3...), then use this code:

Dim oDDoc As DrawingDocument = TryCast(ThisDoc.Document, DrawingDocument)
If oDDoc Is Nothing Then Exit Sub
If oDDoc.ActiveSheet.PartsLists.Count = 0 Then Exit Sub
Dim oPList As PartsList = oDDoc.ActiveSheet.PartsLists(1)
For Each oRow As PartsListRow In oPList.PartsListRows
	If oRow.Expandable Then
		oRow.Visible = False
	End If
Next

 

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

0 Likes
Message 3 of 16

eladm
Collaborator
Collaborator

Hi

 

You can see QTY column with units : mm / in

I want to hide them

1 - only hide them , don't change the value

2- convert them to m or mm (to be able to select ) and get the value without units

 

 

0 Likes
Message 4 of 16

Andrii_Humeniuk
Advisor
Advisor

Understand. The first part of the code hides all rows that have units (mm, in). The second part of the code changes the BaseUnits for all pipes to mm. The third part of unit hiding cannot be done in code because such methods are not available in the API. This can only be done at StyleMang. (see screenshot) .

Dim oDDoc As DrawingDocument = TryCast(ThisDoc.Document, DrawingDocument)
If oDDoc Is Nothing Then Exit Sub
If oDDoc.ActiveSheet.PartsLists.Count = 0 Then Exit Sub
Dim oPList As PartsList = oDDoc.ActiveSheet.PartsLists(1)
For Each oRow As PartsListRow In oPList.PartsListRows
	Try : oRow.Expanded = True: Catch : End Try
	If oRow(4).Value.Contains(".") Then : oRow.Visible = False
	Else : oRow.Visible = True
	End If
Next

Dim oADoc As AssemblyDocument = oPList.ReferencedDocumentDescriptor.ReferencedDocument
For Each oRefDoc As Document In oADoc.AllReferencedDocuments
	If oRefDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject _
		AndAlso oRefDoc.DocumentInterests.HasInterest("{4D39D5F1-0985-4783-AA5A-FC16C288418C}") _
		AndAlso Not oRefDoc.ComponentDefinition.BOMStructure = BOMStructureEnum.kPhantomBOMStructure Then
		Dim oPipeDoc As PartDocument = oRefDoc
		oPipeDoc.ComponentDefinition.BOMQuantity.BaseUnits = "mm"	
	End If
Next

SetPartsList.png

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

0 Likes
Message 5 of 16

eladm
Collaborator
Collaborator

Hi

 

The code didn't do anything (nothing happened after run rule, I tried with the whole code and half of it )

***What did you mean about 1st  , 2nd and 3rd parts ?

We can't use the style manager because it convert the unit  , It need to be with a rule

 

 

0 Likes
Message 6 of 16

Andrii_Humeniuk
Advisor
Advisor

Sorry in my case the QTY column was the fourth in your case it is the second column. You need to change line 7.

If oRow(2).Value.Contains(".") Then : oRow.Visible = False

As for changing in to mm. These changes can be reflected on your table only when created. That is, you need to delete the table and create it again.

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

0 Likes
Message 7 of 16

eladm
Collaborator
Collaborator

Hi

 

this is the part list

eladm_0-1708869144767.png

 

after use the code :

eladm_1-1708869173211.png

 

 

not good , I need to remove the units from the rows with the value with the unit

 

0 Likes
Message 8 of 16

Andrii_Humeniuk
Advisor
Advisor

Hope this is what you need. If so, then you need to use this code whenever there are changes to the model.

Dim oDDoc As DrawingDocument = TryCast(ThisDoc.Document, DrawingDocument)
If oDDoc Is Nothing Then Exit Sub
If oDDoc.ActiveSheet.PartsLists.Count = 0 Then Exit Sub
Dim oPList As PartsList = oDDoc.ActiveSheet.PartsLists(1)
For Each oRow As PartsListRow In oPList.PartsListRows
	Try : oRow.Expanded = True : oRow.Visible = True : Catch : End Try
	Dim oRefRow As DrawingBOMRow = oRow.ReferencedRows(1)
	Dim oRefDoc As Document = oRefRow.BOMRow.ComponentDefinitions(1).Document
	If oRefDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject _
		AndAlso oRefDoc.DocumentInterests.HasInterest("{4D39D5F1-0985-4783-AA5A-FC16C288418C}") _
		AndAlso Not oRefDoc.ComponentDefinition.BOMStructure = BOMStructureEnum.kPhantomBOMStructure Then
		Dim oPipeDoc As PartDocument = oRefDoc
		oPipeDoc.ComponentDefinition.BOMQuantity.BaseUnits = "mm"
		Dim eQty As BOMQuantityTypeEnum = Nothing
		Dim oParam As Inventor.Parameter = Nothing
		Try : oPipeDoc.ComponentDefinition.BOMQuantity.GetBaseQuantity(eQty, oParam)
		Catch : Continue For : End Try
		Dim dLeng As Double = Round(oDDoc.UnitsOfMeasure.ConvertUnits(oParam.Value, "cm", "mm"), 3)
		oRow("QTY").Value = dLeng
	End If
Next

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

0 Likes
Message 9 of 16

A.Acheson
Mentor
Mentor

Hi @eladm 

This operation  would be far easier if you  convert the pipe units of inches to mm in the family part in content center. What is the end goal in stripping the units and leaving lengths of mm and lengths of inches. A user will assume the units incorrectly and you have the wrong cut list. I use tube and pipe and get help set things up so you don't need to do these funky work arounds.

 

 

Is this what you want to achieve in the workaround?

 

Old

21.7 in

756.920 mm

 

New

21.7

756.920

 

How to remove, in a rule loop each cell in that column and find mm and do a string.replace with "".

 

 

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

eladm
Collaborator
Collaborator

Hi

 

The end goal is to remove the units , if a row value : 2 in -> 2 , other row 45mm -> 45

When use tube and pipe you can't change the unit of the pipe.

you don't need to care "  A user will assume the units incorrectly ... " , not "my problem 🙂

 

0 Likes
Message 11 of 16

A.Acheson
Mentor
Mentor

It is possible to change pipe unit globally for the entire pipe family. Place a pipe as custom, changed the units. Go to content center family and replace family template. 

 

If you just want to remove the unit on the partlist row then this mmodification of @Andrii_Humeniuk will do it for "mm". Follow the same principal for "in". Use String replace with the help pagehere. It isn't tested so test on a sample.

 

Keep in mind when you do this the cell value is now static and will receive no update from the model. Great if you have the model complete but it could lead to future errors. 

Dim oDDoc As DrawingDocument = TryCast(ThisDoc.Document, DrawingDocument)
If oDDoc Is Nothing Then Exit Sub
If oDDoc.ActiveSheet.PartsLists.Count = 0 Then Exit Sub
Dim oPList As PartsList = oDDoc.ActiveSheet.PartsLists(1)
For Each oRow As PartsListRow In oPList.PartsListRows
	Try : oRow.Expanded = True : oRow.Visible = True : Catch : End Try
	Dim oRefRow As DrawingBOMRow = oRow.ReferencedRows(1)
	Dim oRefDoc As Document = oRefRow.BOMRow.ComponentDefinitions(1).Document
	If oRefDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject _
		AndAlso oRefDoc.DocumentInterests.HasInterest("{4D39D5F1-0985-4783-AA5A-FC16C288418C}") _
		AndAlso Not oRefDoc.ComponentDefinition.BOMStructure = BOMStructureEnum.kPhantomBOMStructure Then
         If oRow(2).Value.Contains("mm") Then
           oRow(2).Value = Replace(oRow(2).Value, "mm","")
         End If 
	End If
Next

 

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

eladm
Collaborator
Collaborator

Hi

 

Can you change the rule , that it will be change other units (not just mm)?

regards

 

0 Likes
Message 13 of 16

A.Acheson
Mentor
Mentor

Just add and  ElseIf statement with the new units. 

If oRow(2).Value.Contains("mm") Then
           oRow(2).Value = Replace(oRow(2).Value, "mm","")

ElseIf oRow(2).Value.Contains("in") Then
           oRow(2).Value = Replace(oRow(2).Value, "in","")
End If 

 

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

eladm
Collaborator
Collaborator

If I want all the units ?

 

I add also for m :

 If oRow(2).Value.Contains("mm") Then
           oRow(2).Value = Replace(oRow(2).Value, "mm","")
       ElseIf oRow(2).Value.Contains("m") Then
           oRow(2).Value = Replace(oRow(2).Value, "m", "")
	   ElseIf oRow(2).Value.Contains("in") Then
           oRow(2).Value = Replace(oRow(2).Value, "in","")

it didn't convert , only the in & mm was converted

eladm_0-1709097831832.png

 

regards

 

0 Likes
Message 15 of 16

eladm
Collaborator
Collaborator

Hi

the rule work for only tube and pipe parts ? why ? if I add a "simple file (and change the BOM unit in the document setting to m or mm (not each) ) to the assembly . this part will have no affect by the rule

regards

0 Likes
Message 16 of 16

A.Acheson
Mentor
Mentor
Accepted solution

This if statement here controls what to look for. If you dont need tube and pipe filtering the has interest line is specific to that addin so comment off or delete.

 

Old

If oRefDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject _
		AndAlso oRefDoc.DocumentInterests.HasInterest("{4D39D5F1-0985-4783-AA5A-FC16C288418C}") _
		AndAlso Not oRefDoc.ComponentDefinition.BOMStructure = BOMStructureEnum.kPhantomBOMStructure Then
         If oRow(2).Value.Contains("mm") Then
           oRow(2).Value = Replace(oRow(2).Value, "mm","")
         End If 
	End If

 

New

If oRefDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject  Then
         If oRow(2).Value.Contains("mm") Then
           oRow(2).Value = Replace(oRow(2).Value, "mm","")
         End If 
	End If

 

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