Auto Balloon

Auto Balloon

Anonymous
Not applicable
2,318 Views
1 Reply
Message 1 of 2

Auto Balloon

Anonymous
Not applicable

I'm trying to write a program in C# to automate ballooning from a BOM.

The routine must read the BOM and for every row it highlights in all the views the corresponding component.

Then the user must be able to manualy draw a balloon or balloons to the highlighted items.

When done the next row of the BOM is called, etc.

 

I can choose to start with a BOM from our PDM system or the Inventor BOM, partlist or drawingBOM

I tried different ways but I get stuck on it.

I even tried to select the nodes in the browser and called oNode.doselect, but then I can't get the proper type for the selected items to go further?

 

What is the best approach?

Does anybody have an example how to do this?

 

Geert

 

 

 

 

0 Likes
Accepted solutions (1)
2,319 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Accepted solution

So I figured this one out myself!

For those who want this, here is my raw VB.net code:

   

Public Sub AutomaticBallooning(ByVal rstSTK As ADODB.Recordset)

Try

   Dim oDrawDoc As Inventor.DrawingDocument

   oDrawDoc = m_inventorApplication.ActiveDocument

           

   Dim oActiveSheet As Inventor.Sheet

   oActiveSheet = oDrawDoc.ActiveSheet

           

   Dim oPartslist As Inventor.PartsList

   oPartslist = oActiveSheet.PartsLists.Item(1)

           

   Dim oPartslistRow As Inventor.PartsListRow

           

   For Each oPartslistRow In oPartslist.PartsListRows

        oPartslistRow.Visible = False

   Next

           

    For Each oPartslistRow In oPartslist.PartsListRows

         If oPartslistRow.Ballooned = FalseThen

            'make row visible so user sees which row is going to ballooned

            oPartslistRow.Visible =True                   

            Dim strArtnr AsString

            strArtnr = oPartslistRow.Item(4).Value

            CreateBalloonPerOccurencesPerView(strArtnr)              

         End If

         oPartslistRow.Visible =False

   Next

           

   ForEach oPartslistRow In oPartslist.PartsListRows

        oPartslistRow.Visible =True

   Next

           

                    ''Method with Partlist from PDM

                    'Do While rstSTK.EOF = False

                    '    Dim strArtnr As String

                    '    strArtnr = rstSTK.Fields("ARTNR").Value

                    '    CreateBalloonPerOccurencesPerView(strArtnr)

                    '    rstSTK.MoveNext()

                    'Loop

       

   Catch ex As Exception

       MessageBox.Show(ex.ToString)

   End Try

EndSub


PrivateSub CreateBalloonPerOccurencesPerView(ByVal strArtnr AsString)

       Try           

            Dim oDrawDoc As Inventor.DrawingDocument

            oDrawDoc = m_inventorApplication.ActiveDocument

           Dim oActiveSheet As Inventor.Sheet

            oActiveSheet = oDrawDoc.ActiveSheet

           'loop door de views heen

           Dim oDrawingviews As Inventor.DrawingViews

            oDrawingviews = oActiveSheet.DrawingViews

           Dim oDrawingView As Inventor.DrawingView

           ForEach oDrawingView In oDrawingviews

               Dim oDocDesc As Inventor.DocumentDescriptor

                oDocDesc = oDrawingView.ReferencedDocumentDescriptor

               Dim oAsmDef As Inventor.AssemblyComponentDefinition

                oAsmDef = oDocDesc.ReferencedDocument.ComponentDefinition

               Dim oComponentOccurrence As Inventor.ComponentOccurrence

               ForEach oComponentOccurrence In oAsmDef.Occurrences

                   If oComponentOccurrence.Name.Contains(strArtnr) Then

                       Dim oDrawCurves As Inventor.DrawingCurvesEnumerator

                        oDrawCurves = oDrawingView.DrawingCurves(oComponentOccurrence)

                       Dim DrawCurve As Inventor.DrawingCurve

                       ForEach DrawCurve In oDrawCurves

                           Dim oColorRed As Inventor.Color

                            oColorRed = m_inventorApplication.TransientObjects.CreateColor(255, 0, 0)

                            DrawCurve.Color = oColorRed

                       Next

                       'Call create balloon command and wait till its finished

                       Dim oControlDef As Inventor.ControlDefinition

                        oControlDef = 

                                 m_inventorApplication.CommandManager.ControlDefinitions.Item  ("DrawingBalloonCmd")

                       Try

                            oControlDef.Execute()

                       Catch ex As Exception

                       EndTry

                       DoWhile m_inventorApplication.CommandManager.ActiveCommand = "DrawingBalloonCmd"

                            System.Windows.Forms.Application.DoEvents()

                       Loop

                       ForEach DrawCurve In oDrawCurves

                           Dim oColorBlack As Inventor.Color

                            oColorBlack = m_inventorApplication.TransientObjects.CreateColor(0, 0, 0)

                            DrawCurve.Color = oColorBlack

                       Next

                   End If

               Next

           Next

      Catch ex As Exception

            MessageBox.Show(ex.ToString)

       EndTry

End Sub