找回密码 注册 QQ登录
开思网工业级高精度在线3D打印服务

iCAx开思网

CAD/CAM/CAE/设计/模具 高清视频【积分说明】如何快速获得积分?快速3D打印 手板模型CNC加工服务在线3D打印服务,上传模型,自动报价
查看: 3331|回复: 2
打印 上一主题 下一主题

[求助] 新手求助,用SelectByID2命令总是选错边线

[复制链接]
跳转到指定楼层
1
发表于 2017-2-28 14:31:18 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
在做下图中橙色圆圈中倒角的宏程序时,所用的SelectByID2命令总是选不对正确的边线,原因出在哪里?又该如何解决?
求高手解答,谢谢!

下面是代码
  1. Dim swApp As Object

  2. Dim Part As Object
  3. Dim boolstatus As Boolean
  4. Dim longstatus As Long, longwarnings As Long

  5. Sub main()

  6. Set swApp = _
  7. Application.SldWorks

  8. Set Part = swApp.NewDocument("C:\ProgramData\SOLIDWORKS\SOLIDWORKS 2016\templates\gb_part.prtdot", 0, 0, 0)
  9. swApp.ActivateDoc2 "零件4", False, longstatus
  10. Set Part = swApp.ActiveDoc
  11. Dim myModelView As Object
  12. Set myModelView = Part.ActiveView
  13. myModelView.FrameState = swWindowState_e.swWindowMaximized
  14. swApp.SetUserPreferenceToggle swUserPreferenceToggle_e.swInputDimValOnCreate, False
  15. boolstatus = Part.Extension.SelectByID2("右视基准面", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
  16. Part.SketchManager.InsertSketch True
  17. Dim skSegment As Object
  18. Set skSegment = Part.SketchManager.CreateCircle(-0#, 0#, 0#, -0.045, 0, 0#)
  19. Dim myDisplayDim As Object
  20. Set myDisplayDim = Part.AddDimension2(0, 0, 0.09)
  21. Dim myDimension As Object
  22. Set myDimension = Part.Parameter("D1@草图1")
  23. myDimension.SystemValue = 0.09
  24. Part.SketchManager.InsertSketch True
  25. boolstatus = Part.Extension.SelectByID2("草图1", "SKETCH", 0, 0, 0, False, 4, Nothing, 0)
  26. Dim myFeature As Object
  27. 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)
  28. Part.SelectionManager.EnableContourSelection = False
  29. Part.ViewZoomtofit2
  30. boolstatus = Part.Extension.SelectByID2("", "FACE", 0.41, 0, 0, False, 0, Nothing, 0)
  31. Part.SketchManager.InsertSketch True
  32. Set skSegment = Part.SketchManager.CreateCircle(0#, 0#, 0#, -0.0475, 0, 0#)
  33. Set myDisplayDim = Part.AddDimension2(0.41, 0, 0.095)
  34. Set myDimension = Part.Parameter("D1@草图2")
  35. myDimension.SystemValue = 0.095
  36. Part.SketchManager.InsertSketch True
  37. 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)
  38. Part.SelectionManager.EnableContourSelection = False
  39. Part.ViewZoomtofit2
  40. '*******************************************************************************************************************************************************************************
  41. '总是不能选中正确的边线,命令中的那三个数值是边线上某一点的坐标
  42. boolstatus = Part.Extension.SelectByID2("", "EDGE", 0.41, 0, 0.0475, True, 0, Nothing, 0)
  43. Set myFeature = Part.FeatureManager.InsertFeatureChamfer(4, 1, 0.001, 0.78539816339745, 0, 0, 0, 0)
  44. boolstatus = Part.DeSelectByID("倒角1", "BODYFEATURE", 0, 0, 0)
  45. boolstatus = Part.Extension.SelectByID2("", "EDGE", 0.41, 0, 0.045, True, 1, Nothing, 0)
  46. '********************************************************************************************************************************************************************************
  47. Dim radiiArray3 As Variant
  48. Dim radiis3 As Double
  49. Dim dist2Array3 As Variant
  50. Dim dists23 As Double
  51. Dim conicRhosArray3 As Variant
  52. Dim coniRhos3 As Double
  53. Dim setBackArray3 As Variant
  54. Dim setBacks3 As Double
  55. Dim pointArray3 As Variant
  56. Dim points3 As Double
  57. Dim pointDist2Array3 As Variant
  58. Dim pointsDist23 As Double
  59. Dim pointRhoArray3 As Variant
  60. Dim pointsRhos3 As Double
  61. radiiArray3 = radiis3
  62. dist2Array3 = dists23
  63. conicRhosArray3 = coniRhos3
  64. setBackArray3 = setBacks3
  65. pointArray3 = points3
  66. pointDist2Array3 = pointsDist23
  67. pointRhoArray3 = pointsRhos3
  68. Set myFeature = Part.FeatureManager.FeatureFillet3(195, 0.001, 0.01, 0, 0, 0, 0, (radiiArray3), (dist2Array3), (conicRhosArray3), (setBackArray3), (pointArray3), (pointDist2Array3), (pointRhoArray3))
  69. swApp.SetUserPreferenceToggle swUserPreferenceToggle_e.swInputDimValOnCreate, True
  70. End Sub
复制代码



本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 赞一下!赞一下!
2
发表于 2017-2-28 15:46:27 | 只看该作者

马上注册,结交更多同行朋友,交流,分享,学习。

您需要 登录 才可以下载或查看,没有帐号?注册

x
3
 楼主| 发表于 2017-2-28 16:23:05 | 只看该作者

马上注册,结交更多同行朋友,交流,分享,学习。

您需要 登录 才可以下载或查看,没有帐号?注册

x
您需要登录后才可以回帖 登录 | 注册

本版积分规则

3D打印手板模型快速制作服务,在线报价下单!

QQ 咨询|手机版|联系我们|iCAx开思网  

GMT+8, 2024-11-26 09:28 , Processed in 0.027092 second(s), 13 queries , Gzip On, Redis On.

Powered by Discuz! X3.3

© 2002-2024 www.iCAx.org

快速回复 返回顶部 返回列表