Olhado_ Posted January 2, 2009 Posted January 2, 2009 I am trying to find the best way (or any way) to manipulate data in a different window than you started with. I basically have created a new DWG file, which is also the Active Window and now I want to save it. I cannot just use ThisDrawing.SaveAs Filename because it will save the original drawing. I know the new drawing becomes the active window, so if there is a way to switch to the active window, then that will be good too. Is that clear? Is what I am asking possible? Thanks. Quote
rocheey Posted January 3, 2009 Posted January 3, 2009 I am trying to find the best way (or any way) to manipulate data in a different window than you started with. I basically have created a new DWG file, which is also the Active Window and now I want to save it. I cannot just use ThisDrawing.SaveAs Filename because it will save the original drawing. I know the new drawing becomes the active window, so if there is a way to switch to the active window, then that will be good too. Is that clear? Is what I am asking possible? Thanks. You dont need the "active window" thing; this isnt scripting. "ThisDrawing" is easy, and the default, but you can, and should, use your own variable names when dealing with multiple drawings. When you created your new DWG file, you should set a variable to it, and use the variable to reference it; something like this: Sub main() Dim FirstDwg As AcadDocument Dim SecondDwg As AcadDocument ' set the variable "FirstDwg" to some drawing you opened from disk: Set FirstDwg = Application.Documents.Open("c:\MyTestDwg.dwg", False) ' set the variable "SecondDwg" to a drawing you create new: Set SecondDwg = Application.Documents.Add() ' activate the first drawing and zoom extents FirstDwg.Activate: ZoomExtents ' Pop up the name of the active layer, in the second drawing, without activating it MsgBox SecondDwg.ActiveLayer.Name ' clear the Object variables before leaving the sub Set FirstDwg = Nothing Set SecondDwg = Nothing End Sub Quote
Olhado_ Posted January 5, 2009 Author Posted January 5, 2009 Thanks for the help. I tried following your rules in the situation I have; but I cannot seem to get the active window selected. Can you help determine what the next line would be to save the window that pops up? I have also attached the project, in case you need to see it. Private Sub ImportButton_Click() ThisDrawing.SendCommand "filedia" & vbCr & "0" & vbCr ' Set filedia to 0 ThisDrawing.SendCommand "import" & vbCr & "C:\Test.dgn" & vbCr & "" & vbCr & "" & vbCr & "" & vbCr 'Import File dgn file ThisDrawing.SendCommand "filedia" & vbCr & "1" & vbCr ' Set filedia to 1 End 'Close Window End Sub Thanks again. Import_Test.zip Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.