1 Reply Latest reply on Aug 13, 2015 2:34 PM by John Alexander

    Attach sketchblockinstance leaders to entities

    John Alexander

      I have a macro that emulates the behavior of BOM balloons in solidworks 2012 using custom sketch blocks. One piece of functionality that is still missing is the ability to attach leaders from the blocks to the components that they are "linked" to.

       

      The blocks are not actually linked to components like with $PRP because I needed the text to wrap inside the balloon and this doesn't seem to be possible in 2012 (In fact, this is the premise of the entire project, otherwise I would just be customizing existing BOM balloon annotations). My solution to linking them is to collect references to every single balloon whenever the macro runs and pair them up with their associated component. The component names are saved as an invisible attribute in the balloon. Whenever the user needs the balloons to update, they hit a button on a form.

       

      So I have sketchblockinstances and the components that I want to draw leaders to but I cannot figure out how to actually attach the leaders. The only methods that seem to relate to sketchblockinstance leaders are GetLeaderPoints and GetLeaderStyle. The former only allows me to retrieve information about leader geometry and the latter has nothing to do with the position of the leader. Is there an object that I can cast sketchblockinstances as which will allow me to modify their leaders? Any other options?

       

      Failing this, I need a way of ensuring that the component that IS being pointed to by the manually drawn leader is being represented by the balloon. If the user selects one component (A) to generate the balloon and manually attaches the leader to a different component (B), the balloon needs to update according to (B)'s properties. Any ideas are appreciated.

       

      Thank you,

      John

        • Re: Attach sketchblockinstance leaders to entities
          John Alexander

          I have a workaround for this - it isn't pretty but it seems like it will do the trick. I can't directly manipulate the leader as desired but I can get the result that I want.

           

          When calling InsertSketchBlockInstance, the insertion point argument (a mathpoint) determines where the sketchblockinstance is inserted. The instance is essentially just a copy of the sketchblockdefinition. When the sketchblockinstance is placed, the leader geometry is instantiated (regardless of whether or not it is visible). After insertion, although the leader cannot be manipulated, the position of the sketchblockinstance can be. What's more, when the sketchblockinstance is moved, the pointer stays put. In this way, I can insert the blocks where I want them to point, and then move them to where I want them to be located.

           

          I can't seem to get a predictable behavior out of the leader as it is saved. I'm not certain whether it is part of the definition or not - when I manipulate an instance

           

          Please let me know if you are aware of a more direct method of manipulating sketchblock leaders using the 2012 API.