Create block from selectionset

Discussion in 'AutoCAD' started by HydroGis, Oct 18, 2004.

  1. HydroGis

    HydroGis Guest

    Hi all,

    I want to create a block in VBA with all the objects from a specific layer. I want the block name to be the layer name and i want to create an attribute set with the drawing name...

    What i did is make a selectionset with a filter from my layer, then i want to create a block with this selection set, how do i do that?

    Thanks
     
    HydroGis, Oct 18, 2004
    #1
  2. HydroGis

    Jeff Mishler Guest

    Here's an example that should help:

    Sub makeblock(oSS As AcadSelectionSet, sName As String)
    Dim oEnt As AcadEntity
    Dim oBlk As AcadBlock
    Dim dInsPt(0 To 2) As Double
    Dim vEnts() As Object
    Dim I As Long

    ReDim vEnts(0 To oSS.Count - 1)

    For Each oEnt In oSS
    Set vEnts(I) = oEnt
    I = I + 1
    Next
    Set oBlk = ThisDrawing.Blocks.Add(dInsPt, sName)
    ThisDrawing.CopyObjects vEnts, oBlk

    End Sub
     
    Jeff Mishler, Oct 18, 2004
    #2
  3. HydroGis

    HydroGis Guest

    Great Jeff,

    Thanks a lot
     
    HydroGis, Oct 18, 2004
    #3
  4. HydroGis

    Jeff Mishler Guest

    You're welcome. Glad I could help.
     
    Jeff Mishler, Oct 18, 2004
    #4
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.