Guest User

Untitled

a guest
Dec 10th, 2018
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.25 KB | None | 0 0
  1. Dim swApp As Object
  2.  
  3. Dim Part As Object
  4. Dim boolstatus As Boolean
  5. Dim longstatus As Long, longwarnings As Long
  6. Dim skSegment As Object
  7. Dim R1 As Double
  8. Dim R2 As Double
  9. Dim R3 As Double
  10. Dim R4 As Double
  11. Dim R5 As Double
  12. Dim H1 As Double
  13. Dim H2 As Double
  14. Dim H3 As Double
  15. Dim H4 As Double
  16.  
  17. Sub main()
  18.  
  19. Set swApp = Application.SldWorks
  20. Set Part = swApp.ActiveDoc
  21.  
  22. R1 = 20 / 1000
  23. R2 = 30 / 1000
  24. R3 = 80 / 1000
  25. R4 = 90 / 1000
  26. R5 = 120 / 1000
  27. H1 = 10 / 1000
  28. H2 = 5 / 1000
  29. H3 = 8 / 1000
  30. H4 = 6 / 1000
  31.  
  32. ''''''''''''''''''''''''''''''''''''''''''''''
  33. 'Bossage 1''''''''''''''''''''''''''''''''''''
  34. ''''''''''''''''''''''''''''''''''''''''''''''
  35. boolstatus = Part.Extension.SelectByID2("Plan de face", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
  36. Part.SketchManager.InsertSketch True
  37. Dim skSegment As Object
  38. Set skSegment = Part.SketchManager.CreateCircle(0#, 0#, 0#, 0.015723, 0.009153, 0#)
  39. Set skSegment = Part.SketchManager.CreateCircle(0#, 0#, 0#, 0.023747, 0.01492, 0#)
  40. Part.ClearSelection2 True
  41. 'Renommer l'esquisse
  42. Set swSketch = Part.GetActiveSketch2
  43. Set swFeat = swSketch
  44. swFeat.Name = "esq1"
  45. 'Cotation 1
  46. boolstatus = Part.Extension.SelectByID2("Arc1", "SKETCHSEGMENT", 0, 0, 0, True, 0, Nothing, 0)
  47. Set myDisplayDim = Part.AddDimension2(0, 0, 0)
  48. Part.Parameter("D1@esq1").SystemValue = R1 * 2
  49. 'Cotation 2
  50. boolstatus = Part.Extension.SelectByID2("Arc2", "SKETCHSEGMENT", 0, 0, 0, True, 0, Nothing, 0)
  51. Set myDisplayDim = Part.AddDimension2(0, 0, 0)
  52. Part.Parameter("D2@esq1").SystemValue = R2 * 2
  53. Set myFeature = Part.FeatureManager.FeatureExtrusion2(True, False, False, 6, 0, H1, H1, False, False, False, False, 0, 0, False, False, False, False, True, True, True, 0, 0, False)
  54. Part.SelectionManager.EnableContourSelection = False
  55. Part.ClearSelection2 True
  56.  
  57. ''''''''''''''''''''''''''''''''''''''''''''''
  58. 'Bossage 2''''''''''''''''''''''''''''''''''''
  59. ''''''''''''''''''''''''''''''''''''''''''''''
  60. boolstatus = Part.Extension.SelectByID2("Plan de face", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
  61. Part.SketchManager.InsertSketch True
  62. Set skSegment = Part.SketchManager.CreateCircle(0#, 0#, 0#, 0.023747, 0.01492, 0#)
  63. Set skSegment = Part.SketchManager.CreateCircle(0#, 0#, 0#, 0.054088, 0.023947, 0#)
  64. Part.ClearSelection2 True
  65. 'Renommer l'esquisse
  66. Set swSketch = Part.GetActiveSketch2
  67. Set swFeat = swSketch
  68. swFeat.Name = "esq2"
  69. 'Cotation 1
  70. boolstatus = Part.Extension.SelectByID2("Arc1", "SKETCHSEGMENT", 0, 0, 0, True, 0, Nothing, 0)
  71. Set myDisplayDim = Part.AddDimension2(0, 0, 0)
  72. Part.Parameter("D1@esq2").SystemValue = R2 * 2
  73. 'Cotation 2
  74. boolstatus = Part.Extension.SelectByID2("Arc2", "SKETCHSEGMENT", 0, 0, 0, True, 0, Nothing, 0)
  75. Set myDisplayDim = Part.AddDimension2(0, 0, 0)
  76. Part.Parameter("D2@esq2").SystemValue = R3 * 2
  77. Set myFeature = Part.FeatureManager.FeatureExtrusion2(True, False, False, 6, 0, H2, H2, False, False, False, False, 0, 0, False, False, False, False, True, True, True, 0, 0, False)
  78. Part.SelectionManager.EnableContourSelection = False
  79. Part.ClearSelection2 True
  80.  
  81. ''''''''''''''''''''''''''''''''''''''''''''''
  82. 'Bossage 3''''''''''''''''''''''''''''''''''''
  83. ''''''''''''''''''''''''''''''''''''''''''''''
  84. boolstatus = Part.Extension.SelectByID2("Plan de face", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
  85. Part.SketchManager.InsertSketch True
  86. Set skSegment = Part.SketchManager.CreateCircle(0#, 0#, 0#, 0.054088, 0.023947, 0#)
  87. Set skSegment = Part.SketchManager.CreateCircle(0#, 0#, 0#, 0.072393, 0.002382, 0#)
  88. Part.ClearSelection2 True
  89. 'Renommer l'esquisse
  90. Set swSketch = Part.GetActiveSketch2
  91. Set swFeat = swSketch
  92. swFeat.Name = "esq3"
  93. 'Cotation 1
  94. boolstatus = Part.Extension.SelectByID2("Arc1", "SKETCHSEGMENT", 0, 0, 0, True, 0, Nothing, 0)
  95. Set myDisplayDim = Part.AddDimension2(0, 0, 0)
  96. Part.Parameter("D1@esq3").SystemValue = R3 * 2
  97. 'Cotation 2
  98. boolstatus = Part.Extension.SelectByID2("Arc2", "SKETCHSEGMENT", 0, 0, 0, True, 0, Nothing, 0)
  99. Set myDisplayDim = Part.AddDimension2(0, 0, 0)
  100. Part.Parameter("D2@esq3").SystemValue = R4 * 2
  101. Set myFeature = Part.FeatureManager.FeatureExtrusion2(True, False, False, 6, 0, H3, H3, False, False, False, False, 0, 0, False, False, False, False, True, True, True, 0, 0, False)
  102. Part.SelectionManager.EnableContourSelection = False
  103. Part.ClearSelection2 True
  104.  
  105. ''''''''''''''''''''''''''''''''''''''''''''''
  106. 'Bossage 4''''''''''''''''''''''''''''''''''''
  107. ''''''''''''''''''''''''''''''''''''''''''''''
  108. boolstatus = Part.Extension.SelectByID2("Plan de face", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
  109. Part.SketchManager.InsertSketch True
  110. Part.ClearSelection2 True
  111. Set skSegment = Part.SketchManager.CreateLine(R4, 0#, 0#, R3 * Cos(30 * 3.14 / 360), R3 * Sin(30 * 3.14 / 360), 0#)
  112. Set skSegment = Part.SketchManager.CreateLine(R3 * Cos(30 * 3.14 / 360), R3 * Sin(30 * 3.14 / 360), 0#, R4 * 2, 0#, 0#)
  113. Set skSegment = Part.SketchManager.CreateLine(R4 * 2, 0#, 0#, R3 * Cos(30 * 3.14 / 360), R3 * -Sin(30 * 3.14 / 360), 0#)
  114. Set skSegment = Part.SketchManager.CreateLine(R3 * Cos(30 * 3.14 / 360), R3 * -Sin(30 * 3.14 / 360), 0#, R4, 0#, 0#)
  115. Set myFeature = Part.FeatureManager.FeatureExtrusion2(True, False, False, 6, 0, H4, H4, False, False, False, False, 0, 0, False, False, False, False, True, True, True, 0, 0, False)
  116. Part.SelectionManager.EnableContourSelection = False
  117. Part.ClearSelection2 True
  118.  
  119. End Sub
Add Comment
Please, Sign In to add comment