Insert blocks from a sevrver file.

Discussion in 'AutoCAD' started by Alliance Engineering, Aug 4, 2003.

  1. I am looking for a sample code in VBA, of how to insert a block from a
    drawing library which is located on our companies server. Any help would be
    appreciated.

    Thank you

    Mark
     
    Alliance Engineering, Aug 4, 2003
    #1
  2. Alliance Engineering

    Kevin Terry Guest

    Mark,
    Here's the guts of what you want to do. You'll have to come up with a way to
    provide the user with either a list of blocks to choose from, or another way
    to implant the block drawing name into the code (I'm using a userform with a
    list box and label - the 'lblPath.Caption' in this code is the entire
    drawing name and path). Let me know if you have questions.

    Private Sub cmdAttach_Click()

    Dim acBlockRef As AcadBlockReference
    Dim dInsPt(0 To 2) As Double
    Dim vPoint As Variant
    Dim sSelect As String

    'store filename
    sSelect = lblPath.Caption

    'get insertion point from user
    Me.Hide
    vPoint = ThisDrawing.Utility.GetPoint(, "Select insertion point")
    dInsPt(0) = vPoint(0)
    dInsPt(1) = vPoint(1)
    dInsPt(2) = vPoint(2)

    'insert geometry
    Set acBlockRef = ThisDrawing.ModelSpace.InsertBlock(dInsPt, sSelect, 1,
    1, 1, 0)
    acBlockRef.Explode
    acBlockRef.Delete

    Set acBlockRef = Nothing

    End Sub

    HTH,
    Kevin
     
    Kevin Terry, Aug 5, 2003
    #2
  3. Kevin,
    Thank you for your assistance. I'll let you know how it goes and if I have
    any questions.
    Thanks again,
    Mark
     
    Alliance Engineering, Aug 5, 2003
    #3
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.