Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 105,414 VB Programmers for FREE! Ask your question and get quick answers from experts. There are 1,817 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Automatically Generate PDF Files

 
Reply to this topicStart new topic

Automatically Generate PDF Files

friedguy
post 2 Jul, 2008 - 02:38 PM
Post #1


New D.I.C Head

*
Joined: 2 Jul, 2008
Posts: 2

I am working on a project that uses VB to control the application, DWGeditor. Basically, I am starting with a template .dwg file and then inserting others as blocks; essentially layering the files to create a final product. VB has allowed me to create an interface so that I can select various options. Depending on which options are selected different blocks are inserted thereby creating a different diagram. All in all there are about 4,000 different combinations which results in 4,000 unique diagrams. As you can imagine it would not be feasible to generate all these files by hand so I need to automate the process.

This is where I need help. I'm sure I can loop the process pretty easily, but I have no idea where to begin in order to export the file in the automation process. There is a "PDF Out..." feature that exists under the File menu of DWGeditor which I use to manually save the files. If there a way to call this function? The end result should just be a single "Generate" button that will start the process that:

1. Opens template file
2. Inserts blocks
3. Export PDF
4. Close file
5. Go back to #1

Currently I have a .dwg file with the VB script/interface attached. It will open the template file and populate the diagram with the options selected from the interface. I can then manually stop the VB script then select "PDF out..." to create my file. Hopefully this makes sense. Not sure if looking at my current code will help at all, but here are a couple snippets.

CODE
Dim insPrimRelay As DWGeditor.Point                 'Block 8: Primary Relay Box
    Dim blkPrimRelay As DWGeditor.BlockInsert

Dim insRelayNoteNum As DWGeditor.Point              'Block 10: Relay Note Number
    Dim blkRelayNoteNum As DWGeditor.BlockInsert

Dim insSecRelay As DWGeditor.Point                  'Block 9: Secondary Relay Box
    Dim blkSecRelay As DWGeditor.BlockInsert


CODE
'---------------------------------------[OPENS TEMPLATE DOCUMENT]---------------------------------------
    
    Set docMx = Documents.Open("C:\My Documents\Projects\3D Configurator\template-3-0.dwg")

'---------------------------------[SETS SSMR/NON-SSMR AND RELAY OPTIONS]--------------------------------


    If optNonSSMR = True Then           'Adds standard contactor block and notes
        
        Set insContactor = Library.CreatePoint(4.29, 16.29, 0)
        Set blkContactor = docMx.ModelSpace.InsertBlock(insContactor, "NONSSMRBLOCK", 1, 1, 1, 0)
        
        If optOS = True Then            'Adds standard relay block and notes
                    
            Set insNotes = Library.CreatePoint(9.3, 2.03, 0)
            Set blkNotes = docMx.ModelSpace.InsertBlock(insNotes, "NONSSMR_OS_NOTEBLOCK", 1, 1, 1, 0)
        
            Set insPrimRelay = Library.CreatePoint(5.76, 10.56, 0)
            Set blkPrimRelay = docMx.ModelSpace.InsertBlock(insPrimRelay, "(S)RELAYBLOCK", 1, 1, 1, 0)
              
            Set insRelaySeeNote = Library.CreatePoint(6.5, 10.65, 0)
            Set blkRelaySeeNote = docMx.ModelSpace.InsertBlock(insRelaySeeNote, "SEE7BLOCK", 1, 1, 1, 0)
            
        ElseIf optOA = True Then        'Adds optional relay block and notes
        
            Set insNotes = Library.CreatePoint(9.3, 2.03, 0)
            Set blkNotes = docMx.ModelSpace.InsertBlock(insNotes, "NONSSMR_OA_NOTEBLOCK", 1, 1, 1, 0)
        
            Set insPrimRelay = Library.CreatePoint(5.76, 10.56, 0)
            Set blkPrimRelay = docMx.ModelSpace.InsertBlock(insPrimRelay, "(R1-4)RELAYBLOCK", 1, 1, 1, 0)
                
            Set insRelayNote = Library.CreatePoint(18.18, 17.6, 0)
            Set blkRelayNote = docMx.ModelSpace.InsertBlock(insRelayNote, "OA_RELAYNOTEBLOCK", 1, 1, 1, 0)
            
        ElseIf optOB = True Then        'Adds standard and optional relay blocks and notes
        
            Set insNotes = Library.CreatePoint(9.3, 2.03, 0)
            Set blkNotes = docMx.ModelSpace.InsertBlock(insNotes, "NONSSMR_OB_NOTEBLOCK", 1, 1, 1, 0)
        
            Set insPrimRelay = Library.CreatePoint(5.76, 10.56, 0)
            Set blkPrimRelay = docMx.ModelSpace.InsertBlock(insPrimRelay, "(S)RELAYBLOCK", 1, 1, 1, 0)
        
            Set insSecRelay = Library.CreatePoint(15.07, 17.68, 0)
            Set blkSecRelay = docMx.ModelSpace.InsertBlock(insSecRelay, "(R5-8)RELAYBLOCK", 1, 1, 1, 0)
            
            Set insRelayNote = Library.CreatePoint(18.18, 17.6, 0)
            Set blkRelayNote = docMx.ModelSpace.InsertBlock(insRelayNote, "OB_RELAYNOTEBLOCK", 1, 1, 1, 0)
            
        ElseIf optOC = True Then        'Adds dual optional relay blocks and notes
        
            Set insNotes = Library.CreatePoint(9.3, 2.03, 0)
            Set blkNotes = docMx.ModelSpace.InsertBlock(insNotes, "NONSSMR_OC_NOTEBLOCK", 1, 1, 1, 0)
        
            Set insPrimRelay = Library.CreatePoint(5.76, 10.56, 0)
            Set blkPrimRelay = docMx.ModelSpace.InsertBlock(insPrimRelay, "(R1-4)RELAYBLOCK", 1, 1, 1, 0)
        
            Set insSecRelay = Library.CreatePoint(15.07, 17.68, 0)
            Set blkSecRelay = docMx.ModelSpace.InsertBlock(insSecRelay, "(R5-8)RELAYBLOCK", 1, 1, 1, 0)
            
            Set insRelayNote = Library.CreatePoint(18.18, 17.6, 0)
            Set blkRelayNote = docMx.ModelSpace.InsertBlock(insRelayNote, "OC_RELAYNOTEBLOCK", 1, 1, 1, 0)
                      
        End If
User is offlineProfile CardPM

Go to the top of the page


friedguy
post 3 Jul, 2008 - 06:52 AM
Post #2


New D.I.C Head

*
Joined: 2 Jul, 2008
Posts: 2

I've found this... can't figure out what the syntax is to actually call the subroutine though.

Sub Export(FileName As String, Extension As String, [SelectionSet As SelectionSet])
Member of DWGeditor.Document
Exports the file to any of the supported formats. Optionally, pass in a selection set to export only a part of the file. Format is based on the extension in the FileName (default is the DXF format).

I was thinking something like:

CODE
docMx.Export("pdffile", ".pdf")


That just gives an error though. docMx is a Document variable set to the created file.
User is offlineProfile CardPM

Go to the top of the page

Peter3076
post 5 Jul, 2008 - 04:59 AM
Post #3


New D.I.C Head

*
Joined: 5 Jul, 2008
Posts: 4


My Contributions


Oke, I work with Autocad 2008. We use PDFCreator. You can find it on PDForge.com. What I understand is the PDFCreator written in VB5 en fully open source. Maybe you can find what you looking for.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 8/20/08 05:52AM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month