Reply

Balloon object: GetFileName() GetImmediateParent() ???

[ Edited ]

 

Hi Jason,

Thank you for your reply about ballooning. I need more information about each balloon like file name, parent file name, level in CAD strukture ..., so I can identify each part used for example in different sub-assemblies. I use GetTerminator() to get the file name of the part  and GetParent(), GetImmediateParent()... unsuccessfully !!

How can I get the information needed in C++?

Thank you for your support

 

 

Posted by: Abou Mimin
Post date: 12/17/2007 8:22:28 AM

10 REPLIES

Re: Balloon object: GetFileName() GetImmediateParent() ???

 

I would also be interested in the same thing in vb.net (Studio 2015)...

 

I have looked at several articles on here and can not get all the way there. I'm new to the vb, and programming for that matter, world.

 

Any help would be much appreciated!


Thank you!

 

Hello from Oklahoma!

 

Tony


SolidEdgeDev wrote:

 

Hi Jason,

Thank you for your reply about ballooning. I need more information about each balloon like file name, parent file name, level in CAD strukture ..., so I can identify each part used for example in different sub-assemblies. I use GetTerminator() to get the file name of the part  and GetParent(), GetImmediateParent()... unsuccessfully !!

How can I get the information needed in C++?

Thank you for your support

 

 

Posted by: Abou Mimin
Post date: 12/17/2007 8:22:28 AM


 


- Tony

Re: Balloon object: GetFileName() GetImmediateParent() ???

You should know the following relationships when trying to get information from the terminator object of a balloon.

  • The terminator object is either a drawing view geometry, like DVArc, DVLine, etc. or a reference to it.
  • Each of the drawing view geometries has a ModelMember property which you can use to get to its "roots".
  • Check the ComponentType, ComponentName of the ModelMember to identify its type.
  • The ModelMember also has the FileName property
  • You can recursively get the ImmediateParent until the toplevel document, which has no ImmediateParent (=NULL)

Re: Balloon object: GetFileName() GetImmediateParent() ???

Martin,

Thank you for the response.

I have a few questions:

 

1. If I have balloons with BalloonText I would like to keep, how would I be able to get the geometry that is specific to each balloon....would you recursively: DVArc.IsBallooned throughout entire document?

 

2. After reading through several forums on here, I found one which alluded to using ModelNodes. Would this be similar to what you are suggesting?

 

3. Here is the code I was previously working on, my problem lies in searching the through the "ModelNodes," how do I refer to the group of nodes?:

 

Private Sub ButtonBallCheck_Click(sender As Object, e As EventArgs) Handles _                                                                                                                          ButtonBallCheck.Click

 

Dim i As Integer = 0
Dim j As Integer = 0
Dim j_old As Integer = 0
Dim k As Integer = 0
Dim ballMATCH As Boolean = False
Dim failure As Boolean = False
Dim node As ModelNode
Dim nodes As ModelNodes
Dim itemNUM As Integer = 0
Dim fileNAME As String = String.Empty
Dim ballTEXT As String = String.Empty
Dim oWSheets As SectionSheets = oDoc.Sections.WorkingSection.Sheets
Dim oBSheets As SectionSheets = oDoc.Sections.BackgroundSection.Sheets
Dim oSectionSheets As SectionSheets

oApp = Marshal.GetActiveObject("SolidEdge.Application")
oDoc = oApp.ActiveDocument
oSheet = oDoc.ActiveSheet
oBalloonS = oSheet.Balloons

 

If CheckWork.Checked = True And CheckBack.Checked = True Then
   oSectionSheets = oDoc.Sheets
ElseIf CheckWork.Checked = True Then
   oSectionSheets = oWSheets
ElseIf CheckBack.Checked = True Then
   oSectionSheets = oBSheets
Else
   LabelStatus.Text = "Must check at least Working or Background Sheets"
   Exit Sub
End If

 

For Each node In oDoc.node.nodes
   If nodes.IsBallooned = True Then
   If node.ModelType = ModelNodeTypeConstants.igAssemblyNode Then _ 

                                 nodes = node.ModelNodes
   i = i + 1
   BalloonXREF(itemNUM, oSectionSheets, ballTEXT, ballMATCH, failure)
   If failure = True Then
      MsgBox("Part ballooned, but no match: k = " & k & " - " & "Item# =" & itemNUM)
      Exit Sub

   End If
   If ballMATCH = True Then
      fileNAME = nodes.FileName
      itemNUM = nodes.ItemNumber
      xlsheet.Cells(i + 4, j + 3) = ballTEXT
      xlsheet.Cells(i + 4, j + 4) = fileNAME
      ballMATCH = False
   End If
   If j <> j_old Or (j = 0 And i = 1) Then
      xlsheet.Cells(4, j + 3) = oSheet.Name
      j_old = j
   End If
   If k > 1000 Then
      MsgBox("Runtime Error: Check [Balloon Loop in BallCheck] Subroutine.")
      Exit Sub
   End If

Else
   i = i + 1
   BalloonXREF(itemNUM, oSectionSheets, ballTEXT, ballMATCH, failure)
   If failure = True Then
      MsgBox("Part ballooned, but no match: k = " & k & " - " & "Item# =" & itemNUM)
      Exit Sub
   End If
   If ballMATCH = True Then
      fileNAME = node.FileName
      itemNUM = node.ItemNumber
      xlsheet.Cells(i + 4, j + 3) = ballTEXT
      xlsheet.Cells(i + 4, j + 4) = fileNAME
      ballMATCH = False
   End If
   If j <> j_old Or (j = 0 And i = 1) Then
      xlsheet.Cells(4, j + 3) = oSheet.Name
      j_old = j
   End If
   If k > 1000 Then
      MsgBox("Runtime Error: Check [Balloon Loop in BallCheck] Subroutine.")
      Exit Sub
   End If
End If
Next
i = 0
j = j + 4
nodes = Nothing

End Sub


Sub BalloonXREF(ByVal itemNUM As Integer, ByVal oSectionSheets As SectionSheets,
ByRef ballTEXT As String, ByRef ballMATCH As Boolean,
ByRef failure As Boolean)

 

For Each oSheet In oSectionSheets
   For Each oBalloon In oSheet.Balloons
      oBalloon.LinkToPartsList = True
      oBalloon.DisplayByItemNumber = True
      ballTEXT = oBalloon.BalloonText
      If ballTEXT = itemNUM.ToString Then
         ballMATCH = True
         Exit Sub
      End If
      oBalloon.LinkToPartsList = False
      oBalloon.DisplayByItemNumber = False
   Next
Next
failure = True

 

End Sub

 

Anything would help, thank you!

 

- Tony [super new to Visual Studio]

 


- Tony

Re: Balloon object: GetFileName() GetImmediateParent() ???

 I am not quite sure what you are going to achieve with your checks?

Can you explain your final goal? Maybe there is another solution to do that.

Did you already create a PartList on your drawing?

 

I see that you are setting the LinkToPartsList property, which is normally set by SE when you create a part list.

I also noticed that you don't change/increment the itemNUM, if you don't find any match, that means that you will always look for a balloon with the same itemNUM.

Re: Balloon object: GetFileName() GetImmediateParent() ???

[ Edited ]

Yea, I guess you'd need that, ha.  Sorry about that.

 

I am trying to take existing balloons and find the part/asm that they are referencing. Additionally, the drawings do not use the item numbers as the BalloonText [not using the auto-balloon option]. Also we are not using a parts list on the drawing, the LinkToPartsList property came from a suggestion from the following forum [which I believe I have thoroughly confused myself on]:

 

 http://community.plm.automation.siemens.com/t5/Solid-Edge-Developer-Forum/Draft-getting-the-name-of-...

 

As for the itemNUM, I tried a couple different things here, and that could possibly be due to my inability to debug from the "Nodes" errors I keep getting:

 

I was trying to use the "For Each node In [????]"....I have no idea why this won't use SolidEdgeDraft.ModelNodes.

 

Thank you for your time, Martin.


- Tony

Re: Balloon object: GetFileName() GetImmediateParent() ???

Also, I do not understand how to set the "node" to represent the "nodes" in my document...


- Tony

Re: Balloon object: GetFileName() GetImmediateParent() ???

Now, with Spy for Solid Edge you will probably get there. As I don't have SE installed at home, I can't do some tests for you, but will have a look on it tomorrow.

Re: Balloon object: GetFileName() GetImmediateParent() ???

Tony,

here is some simple code which shows for each balloon in the active sheet the filename of the linked object and its component path (bottom-up hierarchy from linked object until the toplevel assembly):

    '----------------------------------------------------------------------
    ' DFT: Get the component information to which a balloon is linked
    '----------------------------------------------------------------------
    Dim objDoc As DraftDocument = objApp.ActiveDocument
    Dim objSheet As Sheet = objDoc.ActiveSheet
    For Each objBall As Balloon In objSheet.Balloons
      Dim objTerminator As Object = Nothing
      Dim x, y, z As Double
      Dim keyPoint As Boolean
      objBall.GetTerminator(objTerminator, x, y, z, keyPoint)
      Dim objObj As Object = objTerminator
      Dim objRef As Reference = objTerminator
      If objRef IsNot Nothing Then
        objObj = objRef.Object
      End If
      Dim objMem As ModelMember = objObj.GetType().InvokeMember("ModelMember", Reflection.BindingFlags.GetProperty, Nothing, objObj, Nothing)
      Console.Write("File: " + objMem.FileName)
      Console.Write(", Component: " + objMem.ComponentName)
      While objMem.ImmediateParent IsNot Nothing
        objMem = objMem.ImmediateParent
        Console.Write(" -> " + objMem.ComponentName)
      End While
      Console.WriteLine()
    Next

Re: Balloon object: GetFileName() GetImmediateParent() ???

Thank you so much!

 

I am getting an issue, as you can see below:

 

 

So does this mean I need to find another way to reference the "objRef"?

 

If so, I believe I might have a solution. On the ST8 SDK, the GetTerminator() example had two subroutines attached to it [as shown at the URL below], is this why the two subroutines were written?

 

https://docs.plm.automation.siemens.com/docs/se/108/api/webframe.html

 

 

 


- Tony