Plausibility check for parts list (drawing)

Plausibility check for parts list (drawing)

MiCAD_LA
Participant Participant
587 Views
6 Replies
Message 1 of 7

Plausibility check for parts list (drawing)

MiCAD_LA
Participant
Participant

Dears,

I'd like to make a kind of plausibility check for the parts list.

For that I implemented a column  named "group".

Some of my parts belongs to such a group like "switch", "case", "cover" and so on.

Now I need to have exactly one "case" and one "cover" in each assembly and at least (one ore more) "switch".

If I don't match this, I only need a msgbox. At the moment I don't have an idea how to manage this.

 

I'm very thankful for ideas 😉 

 

Thanks very much!

0 Likes
Accepted solutions (1)
588 Views
6 Replies
Replies (6)
Message 2 of 7

FINET_Laurent
Advisor
Advisor

Hi @MiCAD_LA,

 

I would go about it this way :

 

Dim Doc As Inventor.AssemblyDocument = ThisApplication.ActiveDocument
Dim AssyCompDef As Inventor.AssemblyComponentDefinition = Doc.ComponentDefinition

Dim iCase As Integer = 0
Dim iCover As Integer = 0
Dim iSwitch As Integer = 0

For Each Occ As Inventor.ComponentOccurrence In AssyCompDef.Occurrences
	Dim d As Inventor.Document = Occ.ReferencedDocumentDescriptor.ReferencedDocument
	Dim p As Inventor.PropertySet = d.PropertySets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")                          
	
	For Each pp As Inventor.Property In p
		If pp.DisplayName = "case" Then iCase = iCase + 1
		If pp.DisplayName = "cover" Then iCase = iCover + 1
		If pp.DisplayName = "switch" Then iCase = iSwitch + 1
			
	Next
Next

If iCase <> 1 Then MsgBox("case :" & iCase)
If iCover <> 1 Then MsgBox("cover :" & iCover)
If iSwitch = 0 Then MsgBox("switch :" & iSwitch)

 

What do you think about this ?

 

Edit : Note that the code iterates through each top part / assembly in the main assembly. It is not going trough each single part / sub assemblies.

 

Kind regards,

FINET L.

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

0 Likes
Message 3 of 7

MiCAD_LA
Participant
Participant

Dear Finet,

thanks very much for your fast response to this item.

Unfortunately I can't do this in the assembly. I have to go through the parts list in on the drawing to find this values in an additional column which I don't have in the assembly.

0 Likes
Message 4 of 7

FINET_Laurent
Advisor
Advisor

@MiCAD_LA,

Are we talking about this? 

FINET_Laurent_0-1690293740694.png

 

Kind regards,

FINET L.

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

0 Likes
Message 5 of 7

MiCAD_LA
Participant
Participant

Dear Finet,

 

yes exactly 😉

0 Likes
Message 6 of 7

FINET_Laurent
Advisor
Advisor
Accepted solution

@MiCAD_LA,

Then, here is a code for the exemple above. The code asks you to pick a drawing part list by mouse :

Dim Doc As Inventor.DrawingDocument = ThisApplication.ActiveDocument
Dim pl As Inventor.PartsList = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingPartsListFilter, "Pick a part list")

Dim iCase As Integer = 0
Dim iCover As Integer = 0
Dim iSwitch As Integer = 0

For Each r As Inventor.PartsListRow In pl.PartsListRows	
	Dim v As String = r.Item("GROUPE").Value
	
	If v = "CASE" Then iCase = iCase + 1
	If v = "COVER" Then iCover = iCover + 1
	If v = "SWITCH" Then iSwitch = iSwitch + 1
			
Next

If iCase <> 1 Then MsgBox("case :" & iCase)
If iCover <> 1 Then MsgBox("cover :" & iCover)
If iSwitch = 0 Then MsgBox("switch :" & iSwitch)

Does this suits your needs? 

 

Kind regards,

FINET L.

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

Message 7 of 7

MiCAD_LA
Participant
Participant

Dear Laurent,

 

thanks very much! 

You really helped me out of this problem.

 

I only changed the mouse point to the used BOM - but this I could do with my low programming knowledge.

 

Thanks again!