The conflict in the Addin

The conflict in the Addin

filat
Advisor Advisor
487 Views
2 Replies
Message 1 of 3

The conflict in the Addin

filat
Advisor
Advisor

I created Addin in which the two Sub. The first Sub handles the assembly. Second Sub handles the part. Addin starts when you save the file and is written in VB.Net. Constantly I see Addin does not work and I have to restart Inventor. I began to track the progress of the Addin and found the cause of the error. If I start the first assembly is saved and then saved the part, the error occurs in line sbs = m_Doc.ComponentDefinition.SurfaceBodies . If I start the first part is saved and then saved the assembly, an error occurs in line fBom = m_Doc.ComponentDefinition.Bom. Why is this happening? Is there a way to fix this conflict?

...
Private Sub m_ApplicationEvents_OnSaveDocument(ByVal DocumentObject As Inventor._Document, _
ByVal BeforeOrAfter As Inventor.EventTimingEnum, ByVal Context As Inventor.NameValueMap, _
ByRef HandlingCode As Inventor.HandlingCodeEnum) Handles m_ApplicationEvents.OnSaveDocument
If BeforeOrAfter = EventTimingEnum.kBefore Then
If DocumentObject.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
If DocumentObject.LevelOfDetailName = "Master" Then ' Or DocumentObject.LevelOfDetailName = "Master1"
m_Ass(DocumentObject)
End If
ElseIf DocumentObject.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
Dim m_partDoc As PartDocument = DocumentObject
Dim m_compDef As PartComponentDefinition = m_partDoc.ComponentDefinition
If m_compDef.BOMStructure = BOMStructureEnum.kNormalBOMStructure Then
m_Part(DocumentObject)
...

Private Sub m_Ass (ByVal m_Doc As Inventor._Document)
Try
Dim fBom As BOM
fBom = m_Doc.ComponentDefinition.Bom
... 
Private Sub m_Part (ByVal m_Doc As Inventor._Document) Try Dim col() As String Dim colv() As String Dim sbs As SurfaceBodies 'Набор тел модели sbs = m_Doc.ComponentDefinition.SurfaceBodies ...
0 Likes
Accepted solutions (1)
488 Views
2 Replies
Replies (2)
Message 2 of 3

filat
Advisor
Advisor

I used a series of Try: 

 

Try
 sbs = m_Doc.ComponentDefinition.SurfaceBodies
Catch ex As Exception
 MsgBox(ex.Message)
End Try

  And got the message. How do I fix it?

 Error.jpg

0 Likes
Message 3 of 3

filat
Advisor
Advisor
Accepted solution

Solution found: need to specify different types of variable

Private Sub m_Perv(ByVal m_Doc As Inventor._AssemblyDocument)
...

Private Sub m_Pokr(ByVal m_Doc As Inventor._PartDocument)
...

 

 

0 Likes