Crear un cubo en Solidworks VBA - Solidworks Automation

Submitted by techrev on Wed, 05/24/2017 - 05:23
solidworks automation

El código para crear un cubo sencillo en Solidworks con VBA (macros)

Editar valores X e Y y Z para personalización

Private Sub CommandButton1_Click()

Dim swApp As Object

Dim Part As Object

Dim boolstatus As Boolean

Dim longstatus As Long, longwarnings As Long

Set swApp = Application.SldWorks

Set Part = swApp.ActiveDoc

Dim myModelView As Object

Set myModelView = Part.ActiveView

myModelView.FrameState = swWindowState_e.swWindowMaximized

boolstatus = Part.Extension.SelectByID2("Front Plane", "PLANE", 0, 0, 0, False, 0, Nothing, 0)

Part.SketchManager.InsertSketch True

Part.ClearSelection2 True

Dim vSkLines As Variant

vSkLines = Part.SketchManager.CreateCenterRectangle(0, 0, 0, 0.05761373872934, -0.04818230819002, 0)

Part.ClearSelection2 True

Part.SketchManager.InsertSketch True

Part.ShowNamedView2 "*Trimetric", 8

Part.ClearSelection2 True

boolstatus = Part.Extension.SelectByID2("Sketch1", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)

Dim myFeature As Object

Set myFeature = Part.FeatureManager.FeatureExtrusion2(True, False, False, 0, 0, 0.1, 0.01, False, False, False, False, 0.01745329251994, 0.01745329251994, False, False, False, False, True, True, True, 0, 0, False)

Part.SelectionManager.EnableContourSelection = False

End Sub

Para más detalles sobre la macro visita : http://www.computeraidedautomation.com/article/record-solidworks-macro-solidworks-automation

 

Tags