• 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. Copy / Duplicate Pages within a .DSN in Orcad Using TCL

Stats

  • State Verified Answer
  • Replies 10
  • Subscribers 13
  • Views 3913
  • Members are here 0
More Content

Copy / Duplicate Pages within a .DSN in Orcad Using TCL

Henry Monro
Henry Monro over 1 year ago

set page_present no
foreach item $pages_names {
# Check if the string matches the current element
if {$item!=NULL} {
set lPageName [DboTclHelper_sMakeCString $item]
set lPage1 [$lSchematic GetPage $lPageName $lStatus]
if {$lPage == $lPage1} {
set page_present yes
}
}
}

if {$page_present!="no"} {

####
Help me Here ==>> COPY/DUPLICATE page multiple times within a same DSN with a unique name depends upon the iterations like pageabc_1, pageabc_2, pageabc3...

####

}

Thanks in Advance

  • Sign in to reply
  • Cancel
Parents
  • CadAP
    0 CadAP over 1 year ago


    #Just giving an sample code how you can copy paste a selected page. You can create your own code with different page name using iteration.

    set dir [file dirname [info script]]
    set file [open "test.xml" a+]

    if {$page_present!="no"} {

    set pagenumber "10"
    set dir [file dirname [info script]]
    set file [open "$dir/test.xml" a+]

    puts $file {<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
    <DialogControls>
    <Control Type="EDIT" Enable="TRUE" Visible="TRUE" Id="2377"> }
    puts $file "<Value><!\[CDATA\[$pagenumber\]\]></Value>"
    puts $file {</Control>
    <Control Type="PUSH_BUTTON" Enable="TRUE" Visible="TRUE" Id="1">
    <Value><![CDATA[OK]]></Value>
    </Control>
    <Control Type="PUSH_BUTTON" Enable="TRUE" Visible="TRUE" Id="2">
    <Value><![CDATA[Cancel]]></Value>
    </Control>
    </DialogControls>}

    close $file

    SelectPMItem "SCHEMATIC1/PAGE2" ; #Itertate over page and select the required page for copy.I am manually selecting page for now.

    Menu "Edit::Copy ; #Command to Copy the selected Page

    SelectPMItem "SCHEMATIC1" ;# Now select the schematic under which you want to add page.I am manually selecting schematic for now.

    #Below command will paste the copy page with page number 10

    Capture> Menu "Edit::Paste" | DialogBox "OK" "$dir/"test.xml"


    }

    Hope this helps!

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • tennywhy
    0 tennywhy 11 months ago in reply to CadAP

    hi CadAP how can i rename schematic name and page name ? i have tried all rename command below

             DboSchematic_Rename
             CISDesign_RenameScheamtic
             CISSchematic_RenameScheamticPage
    but it dont work, could you give me some examples ? thanks
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • CadAP
    0 CadAP 11 months ago in reply to tennywhy

    HI tennywhy,

    Tye using $pSchemticObj SetName $lSchiNewNameCString -->schematic rename and $pPageObj SetName $lPageNewNameCString-->Page rename.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • tennywhy
    0 tennywhy 11 months ago in reply to CadAP

    thanks sir. I did the test as you instructed, but I ran into two other issues, the first, The schematics name is not refreshed after the name is changed.,You have to reopen the file to see the new name. The second is that the rename is invalid for the page., my code as below, help me please. 

    proc renameTest { } {
        set TRUE 1
        set FALSE 0
        set lStatus [DboState]
        set lSession $::DboSession_s_pDboSession
            DboSession -this $lSession
        set lNullObj ""
        set lDesign [$lSession GetActiveDesign]
        if { $lDesign == $lNullObj} {
            puts "Active design not found"]
            return
        }
        #get schematic and rename
            set lSchematicIter [$lDesign NewViewsIter $lStatus $::IterDefs_SCHEMATICS]
            set lView [$lSchematicIter NextView  $lStatus]
            set lNullObj NULL
            set i 0
            while { $lView != $lNullObj} {
                set lSchematic [DboViewToDboSchematic $lView]
                #get pages and rename
                    set lPagesIter [$lSchematic NewPagesIter $lStatus]
                    #get the first page
                    set lPage [$lPagesIter NextPage $lStatus]
                    set j 0
                    while {$lPage!=$lNullObj} {
                        #placeholder: do your processing on $lPage
                        set pgNamC [DboTclHelper_sMakeCString]
                        $lPage GetName $pgNamC
                        set pgNamS [DboTclHelper_sGetConstCharPtr $pgNamC]
                        #rename pages
                        set pgNewC [DboTclHelper_sMakeCString "pg_test$j"]
                        show "lPage $lPage $pgNamS $pgNewC"
                        # rename cant work for pages
                        $lPage SetName $pgNewC
                        set lPage [$lPagesIter NextPage $lStatus]
                        incr j
                    }
                    delete_DboSchematicPagesIter $lPagesIter
                #end rename pages
                set schNewC [DboTclHelper_sMakeCString "sch_test$i"]
                # $lSchematic SetName $schNewC
                set lView [$lSchematicIter NextView $lStatus]
                incr i
            }
        #end rename schematics
            delete_DboLibViewsIter $lSchematicIter
        $lStatus -delete
    }
    thanks advance
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • tennywhy
    0 tennywhy 11 months ago in reply to CadAP

    CadAP could you give me some more advice ? thanks.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • CadAP
    +1 CadAP 11 months ago in reply to tennywhy

    Hi Tennywhy,

    Please try below code just open a design and modify tcl for schematic name and source it.

    set lSession $::DboSession_s_pDboSession
    DboSession -this $lSession
    set lStatus [DboState]

    set lDesignLoc [GetSelectedPMItems]
    set ldesign [GetActivePMDesign]
    set lschiName [DboTclHelper_sMakeCString]
    set lDesignName [DboTclHelper_sMakeCString]
    set lschiNewName [DboTclHelper_sMakeCString "CadAP"]
    set lView [$ldesign GetRoot $lStatus]
    set lSchi [$ldesign GetRootSchematic $lStatus]
    set lPagecount [$lSchi GetPageCount $lStatus]
    # $lSchi GetName $lschiName
    $lSchi SetName $lschiNewName
    Menu "File::Save"

    $ldesign GetName $lDesignName

    set lSchi [$ldesign GetRootSchematic $lStatus]
    $lSchi GetName $lschiName

    set lDesignloc [DboTclHelper_sGetConstCharPtr $lDesignName]


    for {set i 0} {$i <$lPagecount} {incr i} {
    set lPageNewName [DboTclHelper_sMakeCString "Test$i"]
    set lDboPage [$lSchi GetPage $i $lStatus]
    # puts $lDboPage
    $lSchi Rename $lDboPage $lPageNewName
    $lSchi SavePage $lDboPage 1
    }
    Menu "File::Save"
    Menu "File::Close"
    after 1000
    Open "$lDesignloc"

    Try and let me know your feedback.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Reject Answer
    • Cancel
Reply
  • CadAP
    +1 CadAP 11 months ago in reply to tennywhy

    Hi Tennywhy,

    Please try below code just open a design and modify tcl for schematic name and source it.

    set lSession $::DboSession_s_pDboSession
    DboSession -this $lSession
    set lStatus [DboState]

    set lDesignLoc [GetSelectedPMItems]
    set ldesign [GetActivePMDesign]
    set lschiName [DboTclHelper_sMakeCString]
    set lDesignName [DboTclHelper_sMakeCString]
    set lschiNewName [DboTclHelper_sMakeCString "CadAP"]
    set lView [$ldesign GetRoot $lStatus]
    set lSchi [$ldesign GetRootSchematic $lStatus]
    set lPagecount [$lSchi GetPageCount $lStatus]
    # $lSchi GetName $lschiName
    $lSchi SetName $lschiNewName
    Menu "File::Save"

    $ldesign GetName $lDesignName

    set lSchi [$ldesign GetRootSchematic $lStatus]
    $lSchi GetName $lschiName

    set lDesignloc [DboTclHelper_sGetConstCharPtr $lDesignName]


    for {set i 0} {$i <$lPagecount} {incr i} {
    set lPageNewName [DboTclHelper_sMakeCString "Test$i"]
    set lDboPage [$lSchi GetPage $i $lStatus]
    # puts $lDboPage
    $lSchi Rename $lDboPage $lPageNewName
    $lSchi SavePage $lDboPage 1
    }
    Menu "File::Save"
    Menu "File::Close"
    after 1000
    Open "$lDesignloc"

    Try and let me know your feedback.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Reject Answer
    • Cancel
Children
  • tennywhy
    0 tennywhy 11 months ago in reply to CadAP

    Thank you so much sir , that exactly was i want, it's worked perfectly,
    i need digest your code. You've done me a great favor

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • CadAP
    0 CadAP 11 months ago in reply to tennywhy

    tennywhy  Good to hear that helped.

    Keep exploring tcl ......Slight smile

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • tennywhy
    0 tennywhy 11 months ago in reply to CadAP

    Thank you so much, your encouragement is very important to me

    • 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.

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

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