以下はマクロ記録を一部修正したます。動画の下に置きたかったが5000文字までという制約で置けませんでした。
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim Part As SldWorks.PartDoc
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Dim myModelView As Object
Set myModelView = Part.ActiveView
myModelView.FrameState = swWindowState_e.swWindowMaximized
Dim skSegment As Object
Set skSegment = Part.SketchManager.Create3PointArc(0.025, 0.084, 0#, 0.118798, 0.029, 0#, 0.088, 0.073, 0#)
Part.ClearSelection2 True
Set skSegment = Part.SketchManager.CreateCenterLine(0.025, 0.084, 0#, 0.109064, 0.084, 0#)
Part.SetPickMode
Part.ClearSelection2 True
boolstatus = Part.Extension.SketchBoxSelect("0.079", "0.058", "0.000", "0.090", "0.095", "0.000")
boolstatus = Part.Extension.SelectByID2("Arc1", "SKETCHSEGMENT", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Line1", "SKETCHSEGMENT", 0, 0, 0, True, 0, Nothing, 0)
Part.SketchAddConstraints "sgTANGENT"
Part.ClearSelection2 True
Part.SketchManager.InsertSketch True
boolstatus = Part.Extension.SelectByID2("平面", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
Part.SketchManager.InsertSketch True
Part.ShowNamedView2 "*等角投影", 7
Part.ClearSelection2 True
boolstatus = Part.Extension.SetUserPreferenceToggle(swUserPreferenceToggle_e.swSketchAddConstToRectEntity, swUserPreferenceOption_e.swDetailingNoOptionSpecified, False)
boolstatus = Part.Extension.SetUserPreferenceToggle(swUserPreferenceToggle_e.swSketchAddConstLineDiagonalType, swUserPreferenceOption_e.swDetailingNoOptionSpecified, True)
Dim vSkLines As Variant
vSkLines = Part.SketchManager.CreateCornerRectangle(0.061, 0.046, 0, 0.11, -0.05, 0)
Part.ClearSelection2 True
Part.SketchManager.InsertSketch True
boolstatus = Part.Extension.SelectByID2("スケッチ1", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("スケッチ1", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.SelectedFeatureProperties(0, 0, 0, 0, 0, 0, 0, 1, 0, "外側R")
boolstatus = Part.Extension.SelectByID2("スケッチ2", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("スケッチ2", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.SelectedFeatureProperties(0, 0, 0, 0, 0, 0, 0, 1, 0, "入り口")
boolstatus = Part.Extension.SelectByID2("右側面", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
Part.SketchManager.InsertSketch True
Part.ClearSelection2 True
boolstatus = Part.Extension.SetUserPreferenceToggle(swUserPreferenceToggle_e.swSketchAddConstToRectEntity, swUserPreferenceOption_e.swDetailingNoOptionSpecified, False)
boolstatus = Part.Extension.SetUserPreferenceToggle(swUserPreferenceToggle_e.swSketchAddConstLineDiagonalType, swUserPreferenceOption_e.swDetailingNoOptionSpecified, True)
vSkLines = Part.SketchManager.CreateCornerRectangle(-0.041, 0.074, 0, 0.041, 0.033, 0)
Part.ClearSelection2 True
Part.SketchManager.InsertSketch True
boolstatus = Part.Extension.SelectByID2("スケッチ3", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.SelectedFeatureProperties(0, 0, 0, 0, 0, 0, 0, 1, 0, "出口")
boolstatus = Part.Extension.SelectByID2("出口", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
Part.EditSketch
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("Line3", "SKETCHSEGMENT", 0, 0, 0, False, 0, Nothing, 0)
Part.SelectMidpoint
boolstatus = Part.Extension.SelectByID2("Point1@原点", "EXTSKETCHPOINT", 0, 0, 0, True, 0, Nothing, 0)
Part.SketchAddConstraints "sgVERTICALPOINTS2D"
Part.ClearSelection2 True
Part.SketchManager.InsertSketch True
' Named View
'Part.ShowNamedView2 "*等角投影", 7
Part.ViewZoomtofit2
boolstatus = Part.Extension.SelectByID2("外側R", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("入り口", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("入り口", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
Part.EditSketch
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("Line2", "SKETCHSEGMENT", 0, 0, 0, False, 0, Nothing, 0)
Part.SelectMidpoint
boolstatus = Part.Extension.SelectByID2("Point1@原点", "EXTSKETCHPOINT", 0, 0, 0, True, 0, Nothing, 0)
Part.SketchAddConstraints "sgHORIZONTALPOINTS2D"
Part.ClearSelection2 True
Part.SketchManager.InsertSketch True
boolstatus = Part.Extension.SelectByID2("外側R", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
Part.EditSketch
Part.ClearSelection2 True
Part.SketchManager.InsertSketch True
boolstatus = Part.Extension.SelectByID2("外側R", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.ReorderFeature("外側R", "出口")
boolstatus = Part.Extension.SelectByID2("外側R", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
Part.EditSketch
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("Point1", "SKETCHPOINT", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Line1@出口", "EXTSKETCHSEGMENT", 0, 0, 0, True, 0, Nothing, 0)
Part.SketchAddConstraints "sgATPIERCE"
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("Point2", "SKETCHPOINT", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Line4@入り口", "EXTSKETCHSEGMENT", 0, 0, 0, True, 0, Nothing, 0)
Part.SketchAddConstraints "sgATPIERCE"
Part.ClearSelection2 True
Part.SketchManager.InsertSketch True
boolstatus = Part.Extension.SelectByID2("正面", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
Part.SketchManager.InsertSketch True
Part.ClearSelection2 True
Set skSegment = Part.SketchManager.Create3PointArc(0.018, 0.035, 0#, 0.048, 0.004, 0#, 0.046, 0.031, 0#)
Part.ClearSelection2 True
Set skSegment = Part.SketchManager.CreateCenterLine(0.018, 0.035, 0#, 0.167765, 0.035, 0#)
Part.SetPickMode
Part.ClearSelection2 True
boolstatus = Part.Extension.SketchBoxSelect("0.029", "0.028", "0.000", "0.043", "0.044", "0.000")
boolstatus = Part.Extension.SelectByID2("Arc1", "SKETCHSEGMENT", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Line1", "SKETCHSEGMENT", 0, 0, 0, True, 0, Nothing, 0)
Part.SketchAddConstraints "sgTANGENT"
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("Point1", "SKETCHPOINT", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Line3@出口", "EXTSKETCHSEGMENT", 0, 0, 0, True, 0, Nothing, 0)
Part.SketchAddConstraints "sgATPIERCE"
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("Point2", "SKETCHPOINT", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Line2@入り口", "EXTSKETCHSEGMENT", 0, 0, 0, True, 0, Nothing, 0)
Part.SketchAddConstraints "sgATPIERCE"
Part.ClearSelection2 True
Part.SketchManager.InsertSketch True
boolstatus = Part.Extension.SelectByID2("スケッチ4", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.SelectedFeatureProperties(0, 0, 0, 0, 0, 0, 0, 1, 0, "内側R")
End Sub
(Visited 26 times, 1 visits today)