metaldan Posted May 7, 2009 Posted May 7, 2009 hi, I like to make my own WBLOCK command in VBA. I need to select entity ( line, circle, pline, block ) and put it on 2 new dxf files that will be used by other program. The ThisDrawing.Wblock command make only DWG, and the ThisDrawing.export can make DXF but with all the source DWG. I try to make a selection from my source DWG, copy it to a temporary file to make ThisDrawing.export with that file. But when i try this, the copy is put in my source file.....why????? If you have another ideas, don't esitate. homemade wblock.txt Quote
SEANT Posted May 7, 2009 Posted May 7, 2009 The CopyObjects method will copy the objects in place if no other BlockTable is specified. In the example below the ModelSpace of the new file DOC1 was set as the destination for the copied objects. Sub danblock() Dim ss As AcadSelectionSet Dim fType(0) As Integer Dim fData(0) As Variant Dim ent As AcadEntity With ThisDrawing.SelectionSets While .Count > 0 .Item(0).Delete Wend Set ss = .Add("setbom") End With fType(0) = 0 fData(0) = "LINE,CIRCLE,INSERT,LWPOLYLINE" ss.SelectOnScreen fType, fData If ss.Count = 0 Then Exit Sub Dim DOC1 As AcadDocument Dim CurrDoc As AcadDocument Set CurrDoc = ThisDrawing.Application.ActiveDocument Set DOC1 = Documents.Add Dim exportFile As String exportFile = "C:\DXFExprt" 'Modify as needed Dim objCollection() As Object Dim intCount As Integer Dim i As Integer intCount = ss.Count - 1 ReDim objCollection(intCount) For i = 0 To intCount Set objCollection(i) = ss.Item(i) Next CurrDoc.CopyObjects objCollection, DOC1.ModelSpace DOC1.Export exportFile, "DXF", DOC1.SelectionSets.Add("Temp") End Sub Quote
metaldan Posted May 12, 2009 Author Posted May 12, 2009 thank for your help. My function work very well. I try to find the way to scale my selection before making my DXF. I have to make 1 dxf with the same scale of my selection, and another in mm, so, i need to scale my selection by a factor of 25.4 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.