FastFiber

Excel naar Autocad

Gestart door kiredw, ma 09 07 2012, 16:32:01

Vorige topic - Volgende topic

kiredw

Hallo,

Weet iemand hoe ik een dwg block library(dwg met alle blocks) kan koppelen met een nieuwe tekening via excel?


Ik gebruik nu onderstaande code om een block in te voegen. Maar dan moet de desbetreffende tekening wel het block element bevatten. Is er een manier om de block te laden vanuit een andere tekening en die vervolgens in de nieuwe te plaatsen?

b.v.d


Sub MANHOLEBLOCK()

Dim ACAD As AcadApplication 'Create ACAD variable of type AcadApplication

On Error Resume Next 'This tells VBA to ignore errors
Set ACAD = GetObject(, "AutoCAD.Application") 'Get a running instance of the class AutoCAD.Application
On Error GoTo 0 'This tells VBA to go back to NOT ignoring errors
If ACAD Is Nothing Then 'Check to see if the above worked
        Set ACAD = New AcadApplication 'Set the ACAD variable to equal a new instance of AutoCAD
        ACAD.Visible = True 'Once loaded, set AutoCAD to be visible
End If
    ' Add an attribute to the block
    ' Insert the block, creating a block reference
    ' and an attribute reference
    Dim blockRefObj As AcadBlockReference
    Dim insertionPnt(0 To 2) As Double
    insertionPnt(0) = 200
    insertionPnt(1) = 200
    insertionPnt(2) = 300
    Set blockRefObj = ACAD.ActiveDocument.ModelSpace.InsertBlock _
               (insertionPnt, "MANHOLE", 1#, 1#, 1#, 0)
End Sub


sschevers

Kiredw,

Ik zou zorgen dat je je blocken in een aparte directory zet. Dus niet alle blokken in een tekening stoppen.

Vervolgens kun je je blocken op de volgende manier plaatsen

Set blockRefObj = ACAD.ActiveDocument.ModelSpace.InsertBlock  (insertionPnt, "C:\blocklib\MANHOLE.dwg", 1#, 1#, 1#, 0)



stephan