• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Allegro X Scripting - TCL
  3. how to create a design file in capture using tcl

Stats

  • State Verified Answer
  • Replies 4
  • Subscribers 14
  • Views 610
  • Members are here 0
More Content

how to create a design file in capture using tcl

digital1
digital1 1 month ago

Im trying to create a design in capture programatticaly using tcl here is my code so far

# Get the existing DboSession

set lSession $::DboSession_s_pDboSession
DboSession -this $lSession

# Create a DboState

set lStatus [DboState]

# Build a test directory underneath the Capture workspace

set workspace [::orcad::startpage::getCapWorkspacePath]
set projectsDir [file join $workspace "projects"]
set testDir [file join $projectsDir "DboTest"]

file mkdir $testDir

# Define the design name/path

set designPath [file join $testDir "DboTest.dsn"]
set rootName "DboTest"

# Create CString objects for the CreateDesign API

set designNameCString [DboTclHelper_sMakeCString]
DboTclHelper_sSetCString $designNameCString $designPath

set rootNameCString [DboTclHelper_sMakeCString]
DboTclHelper_sSetCString $rootNameCString $rootName

# Create the DboDesign

set lDesign [$lSession CreateDesign  $lStatus  $designNameCString   $rootNameCString]

# Get the root DboSchematic

set lRootSchematic [DboDesign_GetRootSchematic  $lDesign  $lStatus]

# Create the first schematic page

set pageNameCString [DboTclHelper_sMakeCString]
DboTclHelper_sSetCString $pageNameCString "Page 1"

set lPage [$lRootSchematic NewPage  $lStatus  $pageNameCString]

# Save the Dbo design

DboSession_SaveDesign $lSession $lDesign

although this saves the design file it does not save it as an opj file as well also there is no file view or hierarchical view in the capture window. 

i have to exit out of capture and load the design file this creates the opj file and also creates the view window with the file and hierarchical view 

Is there anyone out there that may know what i am doing wrong

Im doing the code in bits and pieces the end result is a kicad file importer for not only capture but later for pcb

Im doing this because kicad imports Altium Binary and CadStar binary format files and also has a pretty good gerber to pcb reverse engineering tool so i can save legacy files that we have lost the design tools for

  • Sign in to reply
  • Cancel

Top Replies

  • TechnoBobby
    TechnoBobby 1 month ago +1 verified
    Hi digital1 , Since the design is being created through the Dbo API, and it is not being opened as a Capture project, so the OPJ and Project Manager views are not initialized until the design is reopened…
  • PatEscher
    PatEscher 1 month ago in reply to digital1 +1 verified
    The easiest way is to create the opj file manually through tcl. proc InitializeOpj {libraryName} { # initialize opj if not exists yet set base [regsub "(.*)(\.olb)" $libraryName "\\1"] set opjPath "$base…
  • TechnoBobby
    +1 TechnoBobby 1 month ago

    Hi digital1 ,

    Since the design is being created through the Dbo API, and it is not being opened as a Capture project, so the OPJ and Project Manager views are not initialized until the design is reopened.

    You can either use the GUI commands to create the project, or continue with the Dbo approach and reopen the design for doing further processing.

    To discover the GUI commands, enable journaling in the Capture Command Window:

    SetOptionBool Journaling TRUE

    Then manually create a project and review the recorded commands.

    If you would like to continue with your current approach, then after saving the design, remove the design from the session using below commands:

    $lSession RemoveDesign $lDesign

    # Delete the session
    DboTclHelper_sDeleteSession $lSession

    # Open the DSN in Capture
    Open {C:/path/to/DboTest.dsn}

    And then continue all further processing on the design opened.

    Hope this helps!

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • digital1
    0 digital1 1 month ago in reply to TechnoBobby

    Hi TechnoBobby 

    Thank you that worked however this bit i didnt like

    # Open the DSN in Capture
    Open {C:/path/to/DboTest.dsn}

    although it worked it gave me a dialog box to click ok on is there any way it can be done without this dialog box.

    Other than that im happy with the result

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • PatEscher
    +1 PatEscher 1 month ago in reply to digital1

    The easiest way is to create the opj file manually through tcl.

    proc InitializeOpj {libraryName} {
        # initialize opj if not exists yet
        set base [regsub "(.*)(\.olb)" $libraryName "\\1"]
        set opjPath "$base.opj"
        set fexist [file exist $opjPath]
        if {!$fexist} {
            set filename [file tail $libraryName]
            set opjContent [open "$opjPath" "w"]
            puts $opjContent {(ExpressProject ""}
            puts $opjContent {  (Folder "Design Resources"}
            puts $opjContent {    (Folder "Library")}
            puts $opjContent "    (File \".\\$filename\""
            puts $opjContent {        (Type "Schematic Library"))}        
            puts $opjContent {    (DOCKED "TRUE")}
            puts $opjContent {    )}
            puts $opjContent {)}
            close $opjContent    
        }
    }

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Reject Answer
    • Cancel
  • digital1
    0 digital1 28 days ago in reply to PatEscher

    Thank you PatEscher  This allowed me to open and see the project structure without any further dialog boxes Although I liked TechnoBobby  version but it gave me a dialog box that needed some user activity. Both versions are valid though.

    I started this project about a year ago because i couldnt get it past the project view stage so thank you guys I can revisit this project and hopefully have a kicad file imporrter for Orcad

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Cadence Guidelines

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2026 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information