0 Replies Latest reply on May 13, 2016 9:31 AM by John Alexander

    Getting Block instance from sketch entities

    John Alexander

      I have a SolidWorks 2012 macro that involves inserting several sketch blocks. When sketch blocks are deleted, the macro needs to handle the deletion event.

       

      Currently, the deletion event is tracked successfully by registering a listener for deletion pre-notify events " DDrawingDocEvents_DeleteItemPreNotifyEventHandler". The handler iterates over the active selections looking for sketch blocks with the correct definition, and calling the block deletion handler on them.

       

      The problem I'm having is that when the user drag-selects sketch blocks (like, with a box), the SelectionManager does not report the block itself as a selected entity, it only reports the arcs inside of the block instance and the insertion points. I can't find a method of determining which SketchBlocks these entities belong to.

       

      One approach that I explored was to iterate over all sketch blocks that I'm keeping track of and compare their entities to those that are being deleted. Unfortunately, sketchblockinstances don't seem to have any methods referring to the entities that they are comprised of.

       

      I'm not sure how to proceed here, surely there must be a way of associating sketch entities with the sketchblockinstances that they are members of.