Making Whole drawing as a block

Discussion in 'AutoCAD' started by balu_sukan, Mar 28, 2005.

  1. balu_sukan

    balu_sukan Guest

    Hi,
    How can i Make, Whole drawing as a block by VBA.
    How can i add selected objects to a block by VBA.

    Balu.
     
    balu_sukan, Mar 28, 2005
    #1
  2. balu_sukan

    juno Guest

    I think you are asking two different questions here. The answer to your first question is: you can not make a whole drawing a block (model space or paper space at a time).

    The answer to your second question is:
    mk:mad:MSITStore:C:\Program%20Files\Common%20Files\Autodesk%20Shared\ACADAUTO.CHM::/idh_blocks_collection.htm
     
    juno, Mar 28, 2005
    #2
  3. Balu, This should get you started.
    gl
    Paul

    '<code>
    Sub blockOut()
    Dim ssObject As AcadSelectionSet
    Dim insPt(2) As Double
    Dim iJc As Integer
    Dim blkScale As Integer: blkScale = 1

    insPt(0) = 0: insPt(1) = 0: insPt(2) = 0

    With ThisDrawing

    ReDim blockobjects(0 To .ModelSpace.Count - 1) _
    As AcadEntity

    Set ssObject = .SelectionSets.Add("SS")

    For iJc = 0 To .ModelSpace.Count - 1
    Set blockobjects(iJc) = .ModelSpace(iJc)
    Next iJc

    ssObject.AddItems blockobjects

    .Wblock "C:\Test.dwg", ssObject

    ssObject.Erase

    .ModelSpace.InsertBlock insPt, _
    "C:\Test.dwg", blkScale, blkScale, blkScale, insPt(0)

    .SelectionSets("SS").Delete

    End With

    Kill "c:\Test.dwg"

    End Sub
    '<code/>
     
    Paul Richardson, Mar 29, 2005
    #3
  4. balu_sukan

    bcoward Guest

    Paul,

    Couldn't you use the CopyObjects method? If you did you could finish this code so I don't have to...lol

    I haven't plugged this up but it saves the iteration loop so I'm thinking it might be a little more streamlined.

    The AutoCAD VBA help files do indicate "To copy multiple objects, use the CopyObjects method or create an array of objects to use with the Copy method....."

    Dim AcadDoc as AcadDocument
    Dim SSet as AcadSelectionSet
    Dim SSetArray as Object

    Set AcadDoc = ThisDrawing.Application.Documents("MyDrawing")
    Set SSet = GetSSetAll()
    ThisDrawing.CopyObjects SSetArray(SSet), AcadDoc.ModelSpace


    Good luck,

    Bob Coward
    CADS, Inc

    800-366-0946
     
    bcoward, Mar 29, 2005
    #4
  5. sure if you want to write nice efficient code..;)
     
    Paul Richardson, Mar 29, 2005
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.