PMI balloon in an aSM using API

Phenom
Phenom

Hi,


after trying without any positive result I must ask wether anybody has a hint or an idea how to create a PMI balloon in an assembly via API

 

What I want do achioeve is to run through all occurences (top occurences) witihn an assembly and create a PMI balloon with occurency name and postion connected to them.

 

I have seen that thee is a SEApp.ActiveDocument.PMI section holding the balloons in it.

 

Using ...balloons.addByTerminator(object, dblX, dblY, dblZ, keypoint) didn't bring me to a proper result

 

Thanks in advance for any hint and tip or code 

 



regards
Wolfgang
9 REPLIES

Re: PMI balloon in an aSM using API

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

AFAIK, there is no API to create any kind of PMI object. There is only access provided to query the PMI objects.

Re: PMI balloon in an aSM using API

Phenom
Phenom

Hi Martin,


thanks for this answer, the seaves me further seeking without any chance of success!

 

I have seen that I was able to access PMI balloons within the ASM, to change the text and son on, but any try to create one was without any positive result.

But strange enough also no error message appeared while testing the code.

Code lines looked correct but no PMI was created.

 

Thanks and let us hope, that the API will be enhanced some time!

 

 



regards
Wolfgang

Re: PMI balloon in an aSM using API

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Hi Wolfgang, 

try this:

 

 

oPartPMI = objDoc.PMI
oRefPlanes = objDoc.RefPlanes
oRefPlane = oRefPlanes.Item(3) ' front
oBalloons = oPartPMI.Balloons
oModel = objDoc.Models.Item(1)
oBody = oModel.Body
oShell = oBody.Shells.item(1)

oEdge1 = oShell.Edges.item(1)
oEdge2 = oShell.Edges.item(2)
oEdge3 = oShell.Edges.item(3)

oAnnotInitData = oBalloons.AnnotInitData
oAnnotInitData.SetPlane(oRefPlane)
oAnnotInitData.SetTerminatorElement(Nothing, False, True, 0, 0, 0.1)
oAnnotInitData.SetConnectElement(oEdge3, False, True, 0.0, 0, 0)

thisBalloon = oBalloons.AddBalloon(oAnnotInitData)
thisBalloon.BalloonText = "Hello"
thisBalloon.Leader = True

This is in Part environement, don't know if it works in Asm environemnt.

 

regards Jürgen

regards

JB
VS2015, SE ST10

Re: PMI balloon in an aSM using API

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Jürgen is right. I had already posted this code some time ago and also found it in my archives.

As the balloon position doesn't come out as desired, I assumed it as NOT working. I updated the code to ASM to try to get better results, but I am still not satisfied with the outcome.

    '----------------------------------------------------------------------
    ' ASM: Create a PMI balloon attached to the first edge of each occurrence
    ' NOTE: the code creates the balloon but NOT at the desired position!!
    '----------------------------------------------------------------------
    Dim objAsmDoc As AssemblyDocument = objApp.ActiveDocument
    Dim objBalloons As Balloons = objAsmDoc.PMI.Balloons
    Dim occID As Integer = 1
    For Each objOcc As Occurrence In objAsmDoc.Occurrences
      Debug.Print(" * " & objOcc.Name)
      Dim objDoc As SolidEdgeDocument = objOcc.OccurrenceDocument
      Dim origX, origY, origZ As Double
      objOcc.GetOrigin(origX, origY, origZ)
      Debug.Print("    Orig(" & origX & ", " & origY & ", " & origZ & ")")
     Dim initData As AnnotInitData = objBalloons.AnnotInitData
      initData.ClearCreationData()
      initData.SetPlane(objAsmDoc.AsmRefPlanes.Item(3)) ' Front (xz) plane
      If TypeOf objDoc Is PartDocument Then
        Dim objMdl As Model = objDoc.Models.Item(1)
        Dim objBody As Body = objMdl.Body
        Dim objEdge As Edge = objBody.Edges(FeatureTopologyQueryTypeConstants.igQueryAll).Item(1)
        Dim objRef As Reference = objAsmDoc.CreateReference(objOcc, objEdge)
        initData.SetConnectElementEx(objRef, True, 0, 0, 0.0)
      Else
        initData.SetConnectElementEx(objOcc, False, origX, origZ, 0.0)
      End If
      'initData.SetTerminatorElement(objFace1, False, False, 0.0, 0.0, 0.0)
      Dim objBall As Balloon = objBalloons.AddBalloon(initData)
      objBall.BalloonText = occID.ToString()
      ' Move the text a little bit away from the terminator
      objBall.SetVertex(0, origX, origZ, 0.0)
      objBall.AddVertex(origX + 0.1, origZ + 0.005, 0.0)
      objBall.BalloonType = DimBalloonTypeConstants.igDimBalloonNone
      objBall.Style.OriginTerminatorType = DimTermTypeConstants.igDimStyleTermFilled
      objBall.Style.TerminatorType = DimTermTypeConstants.igDimStyleTermFilled
      objBall.Style.TerminatorDisplay = DimTermDisplayTypeConstants.igDimStyleTermBoth
      occID += 1
    Next

Re: PMI balloon in an aSM using API

Phenom
Phenom

Hi,

 

 

 

thanks for those great tips and hints.

 

i will give it a test a will keep You informed about the results.

 

Maybe it will take a couple of days till I will find time to realize

 

thanks a lot

 

@MartinBernhard

what exactly makes You dissatisfied?

 



regards
Wolfgang

Re: PMI balloon in an aSM using API

Pioneer
Pioneer

Hi Martin,

 

There is also one API on 

Solid Edge FrameworkSupport Type Library > Balloon Object : SetKeyPoint Method

 which will help in positioning the ballon text.

 

Use index as "1" while using this API. 

 

Thanks,

Onkar

Re: PMI balloon in an aSM using API

Phenom
Phenom

Hi Martin,


does this code work for You?

 

 

I have tried it as it is here and haven't got any balloon!

 

Also no error or something strange, but no new balloon object

 

Tried it on Win10 wit ST8 MP5

 

 



regards
Wolfgang

Re: PMI balloon in an aSM using API

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

I tested it on Win7 + ST8 MP3 with the following result on the Grinder1.asm from the training folder:

PMI_Balloons.jpg

Re: PMI balloon in an aSM using API

Phenom
Phenom

Hi,


ok, the only difference I see at the moment might be the operating system where You have Win 7 while here Win 10 is running

 

MP3 or MP5 should not be the issue

 

I will give another try on it

 

thanks and regards

Wolfgang

 



regards
Wolfgang