• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    AutoCAD Electrical

    Reply
    Contributor
    Posts: 13
    Registered: ‎12-05-2012

    [VBA] Adding a drawing to a project folder

    207 Views, 2 Replies
    12-19-2012 02:54 AM

    Hello,

     

    Is someone know the command to add the activate drawing to the project ?

     

    My problem is that, I am generating various drawing and I would like to add them to a project, If someone know how to do that, It can help me.

     

    ei:

     

    Sub test2()

    Dim AcadObj As AcadApplication
    Dim AcadDoc As AcadDocument

     

    On Error Resume Next
    Set AcadObj = GetObject(, "AutoCAD.Application")
    If Err.Number <> 0 Then
        Set AcadObj = CreateObject("AutoCAD.Application")
        NombreDessinAutocad = 2
    End If
    AcadObj.Visible = True
     

    Set AcadDoc = AcadObj.Application.Documents.Add("C:\PATH\Cartouche_V1.0.dwt")

    Set AcadUtil = AcadDoc.Utility
    Set AcadEspaceObj = AcadDoc.ModelSpace
     
    Set blockRefObj = AcadEspaceObj.InsertBlock(P, "C:\PATH\Mop_V1.1.dwg", 1#, 1#, 1#, 0)
    document to the project

     

    Set ...... **Looking for the command to add my drawing to the project**

     
    End Sub

     

    Regards

     

    Nico

    Please use plain text.
    Valued Contributor
    Posts: 62
    Registered: ‎07-04-2007

    Re: [VBA] Adding a drawing to a project folder

    12-20-2012 09:53 AM in reply to: Nicolas.L

    I could not find any type of command to add a drawing to the project like you are looking for however you could just write some code to add the information to the project.wdp file. Its just a text file so its shouldn't be to difficult. You could also add some other info like Descriptions and Section or Subsection. Its in this format

     

    =section
    ==subsection
    ===description 1
    ===description 2
    ===description 3
    test.dwg

     

    I use notepad to edit the ".wdp" file when I need to add lots of drawings with section and description information quickly.

    You need to close the project before doing this and I always make backups of the file before changing things just in case! 

    Please use plain text.
    Distinguished Mentor
    rhesusminus
    Posts: 569
    Registered: ‎09-21-2007

    Re: [VBA] Adding a drawing to a project folder

    01-14-2013 10:50 PM in reply to: Nicolas.L

    Hi Nico.

     

    You should search for the VLAX-class that makes it easy for VBA to communicate with LISP, as the AcadE API is solely based on AutoLISP.

    Then you should have a look in the help file.

    Look for c:ace_add_dwg_to_project

     

     


    THL
    Please select "Accept As Solution" if this post answers your question. Kudos don't hurt either. ;-)
    Please use plain text.