3dl99 发表于 2017-2-28 14:43:38

求助,用SelectByID2命令总是选错边线

在做下图中橙色圆圈中倒角的宏程序时,所用的SelectByID2命令总是选错边线,如何解决?
求高手解答,谢谢!
下面是代码Dim swApp As Object

Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long

Sub main()

Set swApp = _
Application.SldWorks

Set Part = swApp.NewDocument("C:\ProgramData\SOLIDWORKS\SOLIDWORKS 2016\templates\gb_part.prtdot", 0, 0, 0)
swApp.ActivateDoc2 "零件4", False, longstatus
Set Part = swApp.ActiveDoc
Dim myModelView As Object
Set myModelView = Part.ActiveView
myModelView.FrameState = swWindowState_e.swWindowMaximized
swApp.SetUserPreferenceToggle swUserPreferenceToggle_e.swInputDimValOnCreate, False
boolstatus = Part.Extension.SelectByID2("右视基准面", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
Part.SketchManager.InsertSketch True
Dim skSegment As Object
Set skSegment = Part.SketchManager.CreateCircle(-0#, 0#, 0#, -0.045, 0, 0#)
Dim myDisplayDim As Object
Set myDisplayDim = Part.AddDimension2(0, 0, 0.09)
Dim myDimension As Object
Set myDimension = Part.Parameter("D1@草图1")
myDimension.SystemValue = 0.09
Part.SketchManager.InsertSketch True
boolstatus = Part.Extension.SelectByID2("草图1", "SKETCH", 0, 0, 0, False, 4, Nothing, 0)
Dim myFeature As Object
Set myFeature = Part.FeatureManager.FeatureExtrusion2(True, False, False, 0, 0, 0.41, 0.01, False, False, False, False, 0, 0, False, False, False, False, True, True, True, 0, 0, False)
Part.SelectionManager.EnableContourSelection = False
Part.ViewZoomtofit2
boolstatus = Part.Extension.SelectByID2("", "FACE", 0.41, 0, 0, False, 0, Nothing, 0)
Part.SketchManager.InsertSketch True
Set skSegment = Part.SketchManager.CreateCircle(0#, 0#, 0#, -0.0475, 0, 0#)
Set myDisplayDim = Part.AddDimension2(0.41, 0, 0.095)
Set myDimension = Part.Parameter("D1@草图2")
myDimension.SystemValue = 0.095
Part.SketchManager.InsertSketch True
Set myFeature = Part.FeatureManager.FeatureExtrusion2(True, False, False, 0, 0, 0.24, 0.41, False, False, False, False, 0, 0, False, False, False, False, True, True, True, 0, 0, False)
Part.SelectionManager.EnableContourSelection = False
Part.ViewZoomtofit2
'*******************************************************************************************************************************************************************************
'总是不能选中正确的边线,命令中的那三个数值是边线上某一点的坐标
boolstatus = Part.Extension.SelectByID2("", "EDGE", 0.41, 0, 0.0475, True, 0, Nothing, 0)
Set myFeature = Part.FeatureManager.InsertFeatureChamfer(4, 1, 0.001, 0.78539816339745, 0, 0, 0, 0)
boolstatus = Part.DeSelectByID("倒角1", "BODYFEATURE", 0, 0, 0)
boolstatus = Part.Extension.SelectByID2("", "EDGE", 0.41, 0, 0.045, True, 1, Nothing, 0)
'********************************************************************************************************************************************************************************
Dim radiiArray3 As Variant
Dim radiis3 As Double
Dim dist2Array3 As Variant
Dim dists23 As Double
Dim conicRhosArray3 As Variant
Dim coniRhos3 As Double
Dim setBackArray3 As Variant
Dim setBacks3 As Double
Dim pointArray3 As Variant
Dim points3 As Double
Dim pointDist2Array3 As Variant
Dim pointsDist23 As Double
Dim pointRhoArray3 As Variant
Dim pointsRhos3 As Double
radiiArray3 = radiis3
dist2Array3 = dists23
conicRhosArray3 = coniRhos3
setBackArray3 = setBacks3
pointArray3 = points3
pointDist2Array3 = pointsDist23
pointRhoArray3 = pointsRhos3
Set myFeature = Part.FeatureManager.FeatureFillet3(195, 0.001, 0.01, 0, 0, 0, 0, (radiiArray3), (dist2Array3), (conicRhosArray3), (setBackArray3), (pointArray3), (pointDist2Array3), (pointRhoArray3))
swApp.SetUserPreferenceToggle swUserPreferenceToggle_e.swInputDimValOnCreate, True
End Sub





recieve185 发表于 2017-3-6 11:41:21

我也遇到了类似的问题,由于SOLIDWORKS的选择精度无法准确选择到想要的边。

3dl99 发表于 2017-3-6 17:53:54

本帖最后由 3dl99 于 2017-3-6 17:56 编辑

recieve185 发表于 2017-3-6 11:41
我也遇到了类似的问题,由于SOLIDWORKS的选择精度无法准确选择到想要的边。
谢回复!请问您是怎么解决的呢?这个问题一直困扰我到现在,我编的二次开发程序大多都因为这个问题而建模失败。您有什么解决方法吗?

recieve185 发表于 2017-3-8 14:22:55

目前没有比较好的方法来解决这个问题
页: [1]
查看完整版本: 求助,用SelectByID2命令总是选错边线