Doubt in hierarchy selection

Discussion in 'Cadence' started by noreply, Jul 30, 2009.

  1. noreply

    noreply Guest

    Hi all,
    I have called a big layout as an instance in an different cellview.
    And i require to draw/place the labels on the top level hierarchy(The
    label has to be placed exactly at the same location in the above
    hierarchy).
    From the previous posts in our forum i got a good amount of idea. And
    i have used andrew's code for drawing the label:
    /********************ANDREWS CODE**********************/
    procedure(RLcopyHier()
    xform=list(0:0 "R0" 1)
    ; reverse the list to get the transform the right way around
    /*Rem for the higetcuurentwindow() to work you should have descended
    into the layout instance first*/
    foreach(instPath reverse(geGetInstHierPath(hiGetCurrentWindow()))
    xform=dbConcatTransform(xform car(instPath)~>transform)
    )

    ; now copy selected shapes to the top cellView, with the right
    transformation
    topCv=geGetTopLevelCellView()
    newShapes=foreach(mapcar shape geGetSelSet()
    dbCopyFig(shape topCv xform)
    )
    );procedure
    /
    ************************************************************************/
    The Above code served its purpose well if we select any object and
    execute the procedure.
    Since I wanted lot of labels to be drawn, My idea was to descend down
    the hierarchy and select all the object and then obtain only the
    database id's of the label and then run the above procedure using
    foreach() loop:

    geSelectAll()
    RLlabelList=nil
    RLinstList=geGetSelSet()
    foreach(instName RLinstList
    RLlabelTemp=instName~>objType
    if(RLlabelTemp == "label";to select only the labels
    RLlabelList=cons(instName RLlabelList)
    );if
    );foreach
    length(RLlabelList)
    geDeselectAll()
    for(i 0 length(RLlabelList)
    instName=nth(i RLlabelList)
    geSelectFig(instName)
    RLcopyHier()
    );for


    unfortunately the above code is not running , The error i obtained is
    as follows:

    *Error* geSelectFig: argument #1 should be a database object (type
    template = "d") - nil

    I dont get exactly what the problem is.
    Could anyone please help me out.
    Regards,
    Lokesh.
     
    noreply, Jul 30, 2009
    #1
  2. noreply wrote, on 07/30/09 10:27:
    Two main problems - your use of variable names makes the code rather hard to
    read.... and secondly the for() loop at the end is a very inefficient way of
    doing a foreach loop.

    Also, it seems overkill to select everything just to find the shapes which are
    labels.

    The main issue is that you're using nth() in the second loop (which is the
    inefficient bit) and because you're setting i from 0 to the length of the list,
    the very last value of i will result in nth(i RLlabelList) dropping off the end
    of the list - because 0 is the first, length-1 is the last.

    Much simpler would be to do:

    cv=geGetEditCellView()
    RLlabelList=setof(shape cv~>shapes shape~>objType=="label")
    geDeselectAll()
    foreach(label RLlabelList
    geSelectFig(label)
    )
    RLcopyHier()

    In fact I would probabably alter RLcopyHier to allow you to pass a list of
    objects instead of the selected set:

    procedure(RLcopyHier(@optional (figures geGetSelSet()))
    let((xform topCv newShapes)
    xform=list(0:0 "R0" 1)
    ; reverse the list to get the transform the right way around
    ; Rem for the geGetInstHierPath to work you should have descended
    ; into the layout instance first
    foreach(instPath reverse(geGetInstHierPath(hiGetCurrentWindow()))
    xform=dbConcatTransform(xform car(instPath)~>transform)
    )
    ; now copy selected shapes to the top cellView, with the right
    ; transformation
    topCv=geGetTopLevelCellView()
    newShapes=foreach(mapcar shape figures
    dbCopyFig(shape topCv xform)
    )
    );procedure


    And then you can just do:

    cv=geGetEditCellView()
    RLlabelList=setof(shape cv~>shapes shape~>objType=="label")
    RLcopyHier(RLlabelList)

    If RLcopyHier() is called with no arguments, it works on the selected set.

    Note, I didn't test this code...

    Regards,

    Andrew.
     
    Andrew Beckett, Jul 30, 2009
    #2
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.