5 Replies Latest reply on Aug 16, 2016 1:28 PM by Matthew Cempa

    how to get a reference to a 3d sketch embedded plane

    Matthew Cempa

      Trying to figure out how to get a reference to a plane embedded in a 3d sketch.  I don't see any Get methods in the iSketch interface.  When I record a macro it uses:

       

      Part.Extension.SelectByID2("Plane2", "SKETCHSURFACES", 2.97357990743765, 0.523243105825149, 2.27042269653217, False, 0, Nothing, 0)

       

      However if I don't know the name of the plane I really can't use that.  Any suggestions?

        • Re: how to get a reference to a 3d sketch embedded plane
          Amen Allah Jlili

          maybe the feature named Plane2 and select it?

          ' ******************************************************************************
          ' CADHero.com - amen@cadhero.com - SOLIWORKS API AUTOMATION
          ' ******************************************************************************
          Dim swApp As SldWorks.SldWorks
          Dim swModelDoc As SldWorks.ModelDoc2
          Dim swFeatures As Variant
          Dim swFeature As Feature
          Dim swFeatObj
          Sub main()
          
          
          Set swApp = Application.SldWorks
          
          
          Set swModelDoc = swApp.ActiveDoc
          swFeatures = swModelDoc.FeatureManager.GetFeatures(False)
          For Each swFeatObj In swFeatures
          Set swFeature = swFeatObj
          If swFeature.Name = "Plane2" Then
          swFeature.Select2 True, -1
          End If
          Next swFeatObj
          End Sub
          
          
          • Re: how to get a reference to a 3d sketch embedded plane
            Matthew Cempa

            I've been digging around a bit and here's what I've discovered so far.  If you select the reference plane from the sketch and then use the SelectionMgr.GetSelectedObjectType3(1,-1) method it returns 134 which is not listed in the swSelectType_e enumeration.  And when you use SelectionMgr.GetSelectedObject6(1, -1) it does not return an object.  However SelectionMgr.GetSelectedObjectCount2(-1) returns 1 so it knows something is selected.  I'm starting to think that this may be gap in the API.