I've got a macro question, I'm trying to make a macro that creates a new drawing file from an assembly file, I am then wanting it to generate various views placed in the same place. The last couple of lines are the problem, this macro places views of a certain file but if I open up a different assembly and make a drawing it places the views from the first assembly. Any help would be greatly appreciated. I know very little about Visual Basic, I'm currently taking a class in it but I haven't learned much yet. I'm looking for the command to use that selects the currently opened file name and puts it as a variable to use in the drawing view creation. Also is there any way to make a macro to do the selected dimension. For example a macro to change a dimension that is selected to mm from inches?
' ****************************************************************************** ' D:\DOCUME~1\LUCASL~1\LOCALS~1\Temp\swx4356\Macro1.swb - macro recorded on 05/28/06 by ********************* ' ****************************************************************************** Dim swApp As Object Dim Part As Object Dim SelMgr As Object Dim boolstatus As Boolean Dim longstatus As Long, longwarnings As Long Dim Feature As ObjectSub main()
Set swApp = Application.SldWorks Set Part = swApp.ActiveDoc Set SelMgr = Part.SelectionManager swApp.ActiveDoc.ActiveView.FrameLeft = 0 swApp.ActiveDoc.ActiveView.FrameTop = 0 swApp.ActiveDoc.ActiveView.FrameState = 1 Set Part = swApp.NewDocument("Drawing Template File Path", 12, 0.2794,
0.4318) Set Part = swApp.ActiveDoc Set SelMgr = Part.SelectionManager Part.ViewZoomtofit2 boolstatus = Part.ActivateView("Drawing View1") boolstatus = Part.Extension.SelectByID2("Drawing View1", "DRAWINGVIEW", 0.1173527476636, 0.1787637757009, 0, False, 0, Nothing, 0) Part.EditDelete Dim DrawView As Object Set DrawView = Part.CreateDrawViewFromModelView2("Assembly File Path", "*Isometric", 0.1297821308411, 0.1627831401869, 0) boolstatus = Part.ActivateView("Drawing View4") Set DrawView = Part.CreateDrawViewFromModelView2("Assebly File Path", "*Front", 0.294915364486, 0.1610075140187, 0) Part.ClearSelection2 True End SubLucas Laverman Senior, Mechanical Engineering