chris_czernel

Schematic2DXF

Discussion created by chris_czernel on Jul 20, 2009
Latest reply on Jan 25, 2011 by hoi.fhoon.lim

A question was raised recently regarding whether it was possible to loop through schematic data and generate DXF files for the schematic sheets.

 

One way to implement this is to use CCZ files and CAMCAD. Export CCZ from the schematic tool, load into CAMCAD and run this utility (zip file attached).Note - CAMCAD must be running with a schematic file loaded for this utility to execute properly.

 

The code is very simple:

ScreenHunter_16 Jul. 20 17.04.gif

 

All the user interface does is allow the user to select the output directory and drive.

 

Here is the code (below). The actual creation of DXF files is caused by the ExportDXF API from CAMCAD.

 

Another way to implement this is to use the Export API from CAMCAD (as opposed to ExportDXF), although this method would invoke and display the Export dialogs and the user would need to click through those dialogs as they come up. The implemented method does not show any export dialogs.

 

Option Explicit
Public objCAMCAD As CAMCAD.Application

 

 

 

Private Sub Command1_Click()
Dim lPosition As Long
Dim returnValue As Integer
Dim tempArray As Variant
Dim x As Integer
Dim path As String
Dim counter As Integer
Dim intReturn As Integer

 

 

 

    objCAMCAD.GetActiveFile lPosition ' call camcad api to get the active file position
   
    ' this api takes a fileposition of a view and gives an array of geometry numbers
    ' of sheets of that view
     returnValue = objCAMCAD.GetSchematicSheetArray(lPosition, tempArray)
     path = App.path
     counter = 1
    
     ' now set the view to each sheet, and export dxf
     For x = 0 To UBound(tempArray)
    
        objCAMCAD.SetSchematicSheet lPosition, tempArray(x)
        intReturn = objCAMCAD.ExportDXF(Dir1.path & "\Sheet" & counter & ".dxf", 0.01, True, True, False)
        counter = counter + 1
           
     Next x
    
   
End Sub

 

Private Sub Drive1_Change()
Dir1.path = Drive1.Drive
End Sub

 

Private Sub Form_Load()
    ' these commands establish the connection to CAMCAD
    Set objCAMCAD = New CAMCAD.Application
    Drive1.Drive = "C"
    Dir1.path = App.path
  
End Sub

 

 

The code first gets the Active File (a CAMCAD term for the currently loaded file in CAMCAD). Then it uses the Active File pointer and gets the schematic sheets associated with the active file. It then loops through the sheets, sets the sheets (makes them the visible sheet), and exports DXF for each one. The output file names are "Sheet1.dxf", "Sheet2.dxf", "Sheet3.dxf", and so on for each sheet.

 

This code may be helpful for anyone who is looking for CAMCAD automation possibilities.

Attachments

Outcomes