AnsweredAssumed Answered

How to select a specific cylindrical surface? API

Question asked by Dawid Kozakiewicz on Sep 20, 2020

Hello, i have a problem. How to select a specific cylindrical surface with for example "combobox", and then cut a keyway in the center of that cylinder ? The sketch of the keyway has previously been created based on the dimensions you entered. Additionally, the problem is to move the cut away from the plane to a given distance, so that the keyway has the appropriate dimensions. Below my code and photos of the shaft. Is there anyone who can help me?
Sorry for my English, and thank you . 

 

'Named cylindrical surface

swDoc.Extension.SelectByRay -2.45649421941039E-02, 2.51713048669444E-03, 3.10870617965975E-03, -0.577381545199981, -0.577287712085548, -0.577381545199979, 1.75647421353022E-04, 2, False, 0, 0
swDoc.Extension.SelectByRay -2.54879715887455E-02, 2.17863367765858E-03, 3.35463191669305E-03, -0.577381545199981, -0.577287712085548, -0.577381545199979, 1.75647421353022E-04, 2, False, 0, 0
swDoc.SelectedFaceProperties 0, 0, 0, 0, 0, 0, 0, True, "1"

swDoc.ClearSelection2 True

swDoc.Extension.SelectByID2 "Płaszczyzna górna", "PLANE", 0, 0, 0, False, 0, Nothing, 0
swDoc.SketchManager.InsertSketch True

swDoc.GraphicsRedraw2
swDoc.ShowNamedView2 "*Góra", 5
swDoc.ViewZoomtofit2
swDoc.ClearSelection2 True

'Creating Keyway

swDoc.SketchManager.CreateCenterLine 0#, 0#, 0#, 0#, -0.019806, 0#


swDoc.SketchManager.CreateSketchSlot swSketchSlotCreationType_e.swSketchSlotCreationType_line, swSketchSlotLengthType_e.swSketchSlotLengthType_CenterCenter, 2.13162492719821E-03, 1.57207338380898E-02, 0, 0, 1.81188118811882E-02, 0, 0, 0, 0, 0, 1, False
swDoc.ClearSelection2 True

swDoc.Extension.SelectByID2 "Line1", "SKETCHSEGMENT", 1.77635410599834E-04, 0, 4.70733838089694E-03, False, 0, Nothing, 0
swDoc.Extension.SelectByID2 "Arc1", "SKETCHSEGMENT", 1.43884682585906E-02, 0, 4.44088526499867E-04, True, 0, Nothing, 0


swDoc.AddDimension2 1.03028538147931E-02, 0, 1.43884682585907E-02
swDoc.Parameter("D1@Szkic2").SystemValue = OdlegloscRowk1 / 1000

swDoc.ClearSelection2 True

swDoc.Extension.SelectByID2 "Line4", "SKETCHSEGMENT", 0.016786546301689, 0, 6.21723937099777E-04, False, 0, Nothing, 0
swDoc.Extension.SelectByID2 "Line3", "SKETCHSEGMENT", 1.65200931857892E-02, 0, -1.06581246359912E-03, True, 0, Nothing, 0
swDoc.AddDimension2 1.99839836924871E-02, 0, -7.54950495049486E-03
swDoc.Parameter("D2@Szkic2").SystemValue = SzerokoscRowk1 / 1000
swDoc.ClearSelection2 True

swDoc.Extension.SelectByID2 "Line2", "SKETCHSEGMENT", 1.63424577751893E-02, 0, 0, False, 0, Nothing, 0
swDoc.AddDimension2 1.64312754804894E-02, 0, -5.68433313919611E-03
swDoc.Parameter("D3@Szkic2").SystemValue = DlugoscRowk1 / 1000
swDoc.ClearSelection2 True

swDoc.Extension.SelectByID2 "Szkic2", "SKETCH", 0, 0, 0, False, 0, Nothing, 0
swDoc.FeatureManager.FeatureCut4 True, False, True, 0, 0, GlebokoscRowk1 / 1000, GlebokoscRowk1 / 1000, False, False, False, False, 1.74532925199433E-02, 1.74532925199433E-02, False, False, False, False, False, True, True, True, True, False, 3, 0.005, False, False
swDoc.SelectionManager.EnableContourSelection = False
swDoc.ClearSelection2 True

swDoc.ForceRebuild3 True
swDoc.GraphicsRedraw2
swDoc.ShowNamedView2 "*Izometryczny", 7
swDoc.ViewZoomtofit

Outcomes