Spurs
Mechanical
- Nov 7, 2002
- 297
I am trying to create a macro which will read a dxf file from the C drive, select the units of the dxf file as milimeter, place it into a sketch in the right plane, then extrude the sketch to 26 mm, then save the part file back on the c drive.
Sounds easy right!
When I record the macro using SW2005 starting from a blank part file (set up in mm units), everything works fine during recording and the part is created fine.
But
When I run the macro the next time, the dxf file gets loaded but the scale is 25.4 x larger than what the dxf file parameters are set up in. (It seems that the macro does not recocnize the step where the units of the dxf file are identified as milimeter). This did not happen while I was recording the macro.
In addition the macro wont extrude the sketch the way that it did when the macro was recorded?
The recorded macro is below:
Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim FeatureData As Object
Dim Feature As Object
Dim Component As Object
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
swApp.ActiveDoc.ActiveView.FrameState = 1
boolstatus = Part.Extension.SelectByID2("Right", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
Part.FeatureManager.InsertDwgOrDxfFile "C:\Documents and Settings\Owner\My Documents\cutter.dxf"
Part.ShowNamedView2 "*Trimetric", 8
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("Right", "PLANE", 0, 0, 0, False, 32, Nothing, 0)
Part.FeatureManager.FeatureExtrusion2 True, False, False, 0, 0, 0.026, 0.01, False, False, False, False, 0.01745329251994, 0.01745329251994, False, False, False, False, 1, 1, 1, 0, 0, False
Part.SelectionManager.EnableContourSelection = 0
Part.SaveAs2 "C:\Documents and Settings\Owner\My Documents\Cutter 1.SLDPRT", 0, False, False
End Sub
Also, if anyone can make a recommendaton on how to change the macro so that it will run from the blank Solidworks window without even a opening a document, I would appreaciate it.
Sounds easy right!
When I record the macro using SW2005 starting from a blank part file (set up in mm units), everything works fine during recording and the part is created fine.
But
When I run the macro the next time, the dxf file gets loaded but the scale is 25.4 x larger than what the dxf file parameters are set up in. (It seems that the macro does not recocnize the step where the units of the dxf file are identified as milimeter). This did not happen while I was recording the macro.
In addition the macro wont extrude the sketch the way that it did when the macro was recorded?
The recorded macro is below:
Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim FeatureData As Object
Dim Feature As Object
Dim Component As Object
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
swApp.ActiveDoc.ActiveView.FrameState = 1
boolstatus = Part.Extension.SelectByID2("Right", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
Part.FeatureManager.InsertDwgOrDxfFile "C:\Documents and Settings\Owner\My Documents\cutter.dxf"
Part.ShowNamedView2 "*Trimetric", 8
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("Right", "PLANE", 0, 0, 0, False, 32, Nothing, 0)
Part.FeatureManager.FeatureExtrusion2 True, False, False, 0, 0, 0.026, 0.01, False, False, False, False, 0.01745329251994, 0.01745329251994, False, False, False, False, 1, 1, 1, 0, 0, False
Part.SelectionManager.EnableContourSelection = 0
Part.SaveAs2 "C:\Documents and Settings\Owner\My Documents\Cutter 1.SLDPRT", 0, False, False
End Sub
Also, if anyone can make a recommendaton on how to change the macro so that it will run from the blank Solidworks window without even a opening a document, I would appreaciate it.