AnsweredAssumed Answered

Sketch Entity in Assembly on another Part

Question asked by Sam Pike on May 11, 2018
Latest reply on May 11, 2018 by Sam Pike

This one is giving me fits also.

I have 2 parts in an assembly. The 2 parts are always named differently along with the assembly name. One of the parts we make a sketch on, for accuracy of cutting, and call it "Locating Sketch".

Once in the assembly, the other part is selected (the one that doesn't have the "Locating Sketch"), start a sketch on one of its faces, select the "Locating Sketch" on the other part, convert entity, and Cut-Extrude to a depth of .25"


I have this so far, but I am getting confused. Please help!


Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swAssy As SldWorks.AssemblyDoc
Dim swSelMgr As SldWorks.SelectionMgr
Dim swComp As SldWorks.Component2
Dim boolstatus As Boolean
Dim swMate As Mate2
Dim longstatus As Long

Sub main()

Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swSelMgr = swModel.SelectionManager
Set swComp = swSelMgr.GetSelectedObjectsComponent3(1, 0)

boolstatus = swModel.Extension.SelectByID2("swComp.Name2 + swModel.GetTitle", "COMPONENT", 0, 0, 0, False, 0, Nothing, 0)
swModel.ClearSelection2 True

swModel.SketchManager.InsertSketch True
boolstatus = swModel.Extension.SelectByRay(-0.110609985134488, 6.34999999994079E-03, 4.25014103411172E-02, -0.236548419051214, -0.683632167062601, -0.690428783873951, 1.38817010148556E-03, 2, False, 0, 0)
swModel.ClearSelection2 True

boolstatus = swModel.Extension.SelectByID2("Locating Sketch@" + swComp.Name2 + "@" + swModel.GetTitle, "SKETCH", 0, 0, 0, True, 0, Nothing, 0)
boolstatus = swModel.SketchManager.SketchUseEdge3(False, False)
swModel.ClearSelection2 True

Dim myFeature As Object
Set myFeature = swModel.FeatureManager.FeatureCut4(True, True, False, 0, 0, 0.00635, 0.00635, False, False, False, False, 1.74532925199433E-02, 1.74532925199433E-02, False, False, False, False, False, True, True, True, True, False, 0, 0, False, False)
swModel.SelectionManager.EnableContourSelection = False
swModel.ClearSelection2 True

End Sub