+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Full Member
    Using
    AutoCAD 2004
    Join Date
    Feb 2008
    Posts
    40

    Default create dxf file with selection

    Registered forum members do not see this ad.

    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.
    Attached Files

  2. #2
    Super Member SEANT's Avatar
    Using
    AutoCAD 2012
    Join Date
    Aug 2005
    Location
    Rhode Island
    Posts
    1,968

    Default

    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.


    Code:
    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

  3. #3
    Full Member
    Using
    AutoCAD 2004
    Join Date
    Feb 2008
    Posts
    40

    Default

    Registered forum members do not see this ad.

    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

Similar Threads

  1. standard file selection dialog changes- AutoCAD08
    By KimbleC in forum AutoCAD General
    Replies: 2
    Last Post: 3rd Feb 2009, 06:05 am
  2. Create a PDF from DWG file
    By dark wanderer in forum AutoCAD General
    Replies: 6
    Last Post: 21st Jan 2009, 03:08 pm
  3. Create a Selection Set from Exploded MTEXT?
    By ILoveMadoka in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 11th Dec 2008, 10:08 am
  4. AutoCAD tutorial: Create a complex selection filter
    By AutoCAD Tips Blog in forum AutoCAD RSS Feeds
    Replies: 0
    Last Post: 27th Aug 2008, 12:50 am
  5. Replies: 0
    Last Post: 5th Sep 2006, 12:18 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts