I am looking for some example code that will add a balloon to a drawing, attach it to a magnetic line and attach the leader to a feature displayed in the view. My actual question is at the end but I want to explain what I have done so far and what I am trying to do so I am not wasting anyone's time going back and forth with questions.
Basically what I want is the standard Auto Balloon functionality in Solidworks replicated in my code, but I want to control where the balloons are placed around the view and the order they are displayed in. I have tried using the AutoBalloon example code with surprisingly poor results; the magnetic lines do not get created even though "autoBalloonParams.InsertmagneticLine=true" and that results in the balloons being displayed too far away from the view. Also, the leaders cross all over the view making my drawing look like spaghetti.
I changed my approach to first activate the view and select it using SelectByID2, then create four magnetic lines outside the extents of my view, and for each magnetic line (left, top, right and bottom) I iterate through all the features displayed in the view looking for the features I want attached to that specific magnetic line( odd numbered features on left magnetic line, even numbered features on right magnetic line, etc.). Once I find the feature I want displayed on that specific magnetic line, I create a set of BallonOptions, insert a note named vNote using
InsertBOMBalloon2(balloonOptions) and then attach this vNote to the magnetic line using magLine.AddNote(Note, 00000.1). This code works except all the leaders point to 0,0,0 and because of that the text in the note is displayed as a rectangle with an X in it.
So my question is this: While in a sheet and iterating through the features displayed in the view, how do I get a point on the selected feature to set the balloon's leader to attach to? I was hoping "swSelMgr.GetSelectionSpecification(index, selectByString, objectTypeStr, objectTypeInt, X, Y, Z)" would provide me a position on the selected feature but the values are always 0,0,0, even if I change selectByString = "" as the API suggests. If I use Solidworks proper and insert AutoBalloons. it finds points on the feature to attach the leaders to, how do I get those same points through code?
Many thanks in advance for taking the time to read and hopefully provide a solution