Link betwwn Autocad and VB

Discussion in 'AutoCAD' started by qudeiri, Jul 15, 2004.

  1. qudeiri

    qudeiri Guest

    Hi Friends, please tell me how can I change the variables of drawing drawn by AutoCAD by using different software Visual basic thank you for your help
     
    qudeiri, Jul 15, 2004
    #1
  2. qudeiri

    john m Guest

    you mean like thisdrawing.setvariable "CLAYER", "myLayer" ??

    by AutoCAD by using different software Visual basic thank you for your help
     
    john m, Jul 21, 2004
    #2
  3. qudeiri

    qudeiri Guest

    in fact I have one drawing of AutoCAD it is contain some entities and blocks, I want to modify this blocks and entities (move one items or more, copy , rotate,... ) from out side of AutoCAD by Visual basic, Looking forward to your help
    Yours
    Qudeiri
     
    qudeiri, Jul 22, 2004
    #3
  4. qudeiri

    MP Guest

    connect to acad application object then manipulate document object as
    desired

    this is probably not good coding, but it is one way to get acad from vb

    eg:
    Dim oAcad as AcadApplication
    set oAcad = GetAcad
    debug.print "Current drawing: " & oAcad.ActiveDocument.Name

    etc


    Public Function GetAcad(Optional sDwgName As String, Optional AcVisible As
    Boolean = True) As AcadApplication
    Dim oAcadApp As AcadApplication
    Dim oAcadDoc As AcadDocument
    Dim i As Integer: i = 0

    On Error Resume Next
    If Not IsEmpty(sDwgName) Then
    Set oAcadDoc = GetObject(sDwgName)
    If Not oAcadDoc Is Nothing Then
    Set oAcadApp = oAcadDoc.Application
    End If

    If Not oAcadApp Is Nothing Then
    If oAcadApp.Documents.Count > 1 Then
    oAcadApp.ActiveDocument = oAcadDoc
    End If
    End If
    Else
    Set oAcadApp = GetObject(, "AutoCAD.Application")
    If Err Then
    Err.Clear
    Restart:
    Set oAcadApp = CreateObject("AutoCAD.Application")

    If Err.Number = 91 Then
    Err.Clear
    If i = 3 Then
    Exit Function
    Else
    GoTo Restart
    i = i + 1
    End If
    Else
    Err.Clear
    End If
    End If

    End If

    oAcadApp.Visible = AcVisible
    Set GetAcad = oAcadApp
    End Function


    hope that helps you get started
    Mark

    blocks, I want to modify this blocks and entities (move one items or more,
    copy , rotate,... ) from out side of AutoCAD by Visual basic, Looking
    forward to your help
     
    MP, Jul 22, 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.