2 Replies Latest reply on Jan 28, 2014 8:10 AM by Jason Swackhamer

    Can't determine sketch block from selected entity

    Jason Swackhamer

      Am writing a program that, in the context of an assembly, takes a heterogenous selection set (might be a sketch and/or sketch entities and/or sketch blocks), filters out complete circles, and determines their centers in the current sketch space.


      I got through what I thought was going to be the hard part, selecting a sketch with nested block instances, but now have hit a brick wall when selecting individual arcs that are part of a sketch block. I can't determine to what block the selection, if any, the selection belongs to. This is necessary because the arc returns its center coordinates in the context of the block definition, not the active sketch. So to get the correct center location in the active sketch, the block transforms are required.


      There doesn't seem to be any method or property to determine what block a sketch segment belongs to, so I went ahead programmed to check the selected arc against the entire collection of arcs in the base sketch (all the arcs in all the sketch blocks) to find the one I want the center data for. However, none of the comparison techniques work. I've tried both swapp.issame and modeldocextension.issamepersistentID. Neither works, I think because the objects are obtained in different contexts. The original arc is a selection object, and the comparison arc object is captured programmatically in the context of a sketch block.


      At this point, the only solution I can think of is to create a sketchpoint, add a concentric relation to the arc, obtain the point's center, and delete it.


      I feel like I'm missing something obvious...any suggestions?


      -Jason S.