Home > Community > Forums > Custom IC SKILL > Is it possible to have a "Copy and Paste" function like the "Yank and Paste" ?

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

 Is it possible to have a "Copy and Paste" function like the "Yank and Paste" ? 

Last post Thu, Sep 17 2009 3:06 PM by Andrew Beckett. 9 replies.
Started by zeroskills 16 Sep 2009 03:01 PM. Topic has 9 replies and 2171 views
Page 1 of 1 (10 items)
Sort Posts:
  • Wed, Sep 16 2009 3:01 PM

    Is it possible to have a "Copy and Paste" function like the "Yank and Paste" ? Reply

    Is it possible to have a "Copy and Paste" function like the "Yank and Paste"?

    The Yank  function some what is a Copy function except it literaly "cut" what ever is drawn over by a selection box, if you select half of a device using Yank, you'll only get half of it.

    Is it possible to have something like this:

    - select devices, wires etc. either by selection box (dragging a mouse from 1 point to another) or by selecting individual or by group,

    - then which ever you selected, you can "copy it" like a Yank, then you can paste it.

    Some uses for it for exmaple:

    I've done this with Yank and Paste but i don't know what origin it's using. instead of opening the contact window to instanciate a via, you can just copy a via then when you want a via, just paste it. yes, you can do it manually, select a via then copy, then copy etc. but would it be nice to just copy once then paste it endlessly? 

     

     

    • Post Points: 20
  • Thu, Sep 17 2009 1:50 AM

    Re: Is it possible to have a "Copy and Paste" function like the "Yank and Paste" ? Reply

    Hi zeroskills,

    I have some code to do this; I'll post it later.

    Regards,

    Andrew

     

    • Post Points: 20
  • Thu, Sep 17 2009 6:20 AM

    Re: Is it possible to have a "Copy and Paste" function like the "Yank and Paste" ? Reply

    Thanks again Andrew! 

    • Post Points: 20
  • Thu, Sep 17 2009 6:31 AM

    Re: Is it possible to have a "Copy and Paste" function like the "Yank and Paste" ? Reply

    OK, here's the code I promised earlier:

    /* abCopyPaste.ils
    
    Author     A.D.Beckett
    Group      Custom IC (UK), Cadence Design Systems Ltd.
    Language   SKILL
    Date       Nov 24, 2008 
    Modified   
    By         
    
    A package to copy and paste into a buffer (default lib/copyBuffer/copyBuffer
    where lib is the same library you're working in). Smarter than yank/paste
    
    ; copy into buffer cellView
    abCopyPaste->copy()
    
    ; paste from buffer cellView
    abCopyPaste->paste()
    
    ; without this, the copyBuffer is in the same library as
    ; the cell being edited
    abCopyPaste->setOption('bufferLib "mylib")
    
    ; normally uses the reference point, but can also prompt
    ; for it
    abCopyPaste->setOption('promptRefPoint t)
    
    ***************************************************
    
    SCCS Info: @(#) abCopyPaste.ils 11/24/08.13:53:51 1.1
    
    */
    
    (importSkillVar abCopyPaste)
    (setq abCopyPaste
          (let (
    	    (options (makeTable 'options nil))
    	    (optionNames '(bufferLib bufferCell bufferView 
    				     promptRefPoint))
    	    )
    	/***************************************************************
    	*                                                              *
    	*                (setOption option value "sg")                 *
    	*                                                              *
    	*  Exported function for setting an option for the copy/paste  *
    	*    package. Needs the name of the option and a value. The    *
    	*     name is checked to ensure it is a valid option name.     *
    	*                                                              *
    	***************************************************************/
    	(defun setOption (option value "sg")
    	  (if (memq option optionNames)
    	    (setarray options option 
    		      (if (listp value) (copy value) value)
    		      )
    	    (error "Unrecognised option %L - must be one of %L\n"
    		   option optionNames)
    	    )
    	  ) ; defun setOption
    	/***************************************************************
    	*                                                              *
    	*                 (getOption @optional option)                 *
    	*                                                              *
    	*  Exported function for getting the value of an option or a   *
    	*               list of the legal option names.                *
    	*                                                              *
    	***************************************************************/
    	(defun getOption (@optional option)
    	  (if option
    	    (if (memq option optionNames)
    	      (arrayref options option)
    	      (error "Unrecognised option %L - must be one of %L\n"
    		     option optionNames)
    	      )
    	    (sort (copy optionNames) 'alphalessp)
    	    )
    	  ) ; defun getOption
    	/***************************************************************
    	*                                                              *
    	*                         (copy [cv])                          *
    	*                                                              *
    	*   Exported function to copy selected objects into a buffer   *
    	*                                                              *
    	***************************************************************/
    	(defun copy (@optional (cv (geGetEditCellView)))
    	  (let (buffer refPoint transform)
    	    (setq buffer 
    		  (dbOpenCellViewByType
    		    (or (arrayref options 'bufferLib)
    			(getq cv libName))
    		    (arrayref options 'bufferCell)
    		    (arrayref options 'bufferView)
    		    "maskLayout"
    		    "w"
    		    ))
    	    (unless buffer
    	      (error "Could not create copy buffer %s/%s/%s"
    		     (or (arrayref options 'bufferLib)
    			 (getq cv libName))
    		     (arrayref options 'bufferCell)
    		     (arrayref options 'bufferView)
    		     ))
    	    (setq refPoint
    		  (if (arrayref options 'promptRefPoint)
    		    (enterPoint ?prompts 
    				(list "Point at the reference point for the copy:"))
    		    (leGetRefPoint cv)))
    	    (setq transform
    		  (list (mapcar minus refPoint) "R0" 1.0))
    	    (foreach fig (geGetSelectedSet cv)
    		     (dbCopyFig fig buffer transform)
    		     )
    	    (dbSave buffer)
    	    (dbClose buffer)
    	    )
    	  )
    	/***************************************************************
    	*                                                              *
    	*                           (paste)                            *
    	*                                                              *
    	* Exported function to paste buffer into cellView at prompted  *
    	*                            point                             *
    	*                                                              *
    	***************************************************************/
    	(defun paste ()
    	  (enterPoint ?prompts (list "Point at destination location:")
    		      ?doneProc "abCopyPaste->pasteDone"
    		      )
    	  t
    	  )
    	/***************************************************************
    	*                                                              *
    	*                 (pasteDone wid done points)                  *
    	*                                                              *
    	*   Exported function (used by enterFunction in (paste)) to    *
    	*                   actually do the pasting.                   *
    	*                                                              *
    	***************************************************************/
    	(defun pasteDone (wid done points)
    	  (let (transform cv buffer)
    	    (when done
    	      (setq transform (list (car points) "R0" 1.0))
    	      (setq cv (geGetEditCellView wid))
    	      (setq buffer (dbOpenCellViewByType
    			     (or (arrayref options 'bufferLib)
    				 (getq cv libName))
    			     (arrayref options 'bufferCell)
    			     (arrayref options 'bufferView)
    			     "maskLayout"
    			     "r"
    			     ))
    	      (if buffer
    		(progn
    		  (foreach objs 
    			   (list
    			     (getSGq buffer shapes)
    			     (getSGq buffer instances)
    			     (getSGq buffer vias)
    			     (getSGq buffer figGroups)
    			     (getSGq buffer mosaics)
    			     (getSGq buffer blockages)
    			     (getSGq buffer rows)
    			     (getSGq buffer markers)
    			     (getSGq buffer areaBoundaries)
    			     (getSGq buffer guides)
    			     (getSGq buffer routes)
    			     (getSGq buffer steiners)
    			     )
    			   (foreach fig objs
    				    (dbCopyFig fig cv transform)
    				    ) ; foreach fig
    			   ) ; foreach objs
    		  (dbClose buffer)
    		  )
    		(warn "Could not open copy buffer %s/%s/%s"
    		      (or (arrayref options 'bufferLib)
    			  (getq cv libName))
    		      (arrayref options 'bufferCell)
    		      (arrayref options 'bufferView)
    		      )
    		)
    	      t
    	      ) ; when
    	    ) ; let
    	  ) ; defun pasteDone
    	;----------------------------------------------------------------
    	; Defaults
    	;----------------------------------------------------------------
    	(setarray options 'bufferLib nil)
    	(setarray options 'bufferCell "copyBuffer")
    	(setarray options 'bufferView "copyBuffer")
    	;----------------------------------------------------------------
    	; The DPL containing all the exported functions for the
    	; package
    	;----------------------------------------------------------------
    	(list nil
    	  'setOption setOption
    	  'getOption getOption
    	  'copy copy
    	  'paste paste
    	  'pasteDone pasteDone
    	  ) ; list
    	) ; let
          ) ; setq abCopyPaste
    

    We do also have a few enhancement requests asking for a more conventional copy-paste mechanism to be built into the tools.

    Regards,

    Andrew.

    • Post Points: 20
  • Thu, Sep 17 2009 7:21 AM

    Re: Is it possible to have a "Copy and Paste" function like the "Yank and Paste" ? Reply

    Hi Andrew,

    This is what i did: 

    load("/user/me/abCopyPaste.ils")
    hiSetBindKey("Layout" "Ctrl<Key>6" "abCopyPaste->copy()")
    hiSetBindKey("Layout" "Alt<Key>6" "abCopyPaste->paste()")

    but i get this error for copy:

    *Error* dbCopyFig: Invalid point - nil 

    <<< Stack Trace >>>

    dbCopyFig(fig buffer transform)

    foreach(fig geGetSelectedSet(cv) dbCopyFig(fig buffer transform))

    let((fig) foreach(fig geGetSelectedSet(cv) dbCopyFig(fig buffer transform)))

    let((buffer refPoint transform) (buffer = dbOpenCellViewByType((& || &) options[&] options[&] "maskLayout" "w")) unless(buffer error("Could not create copy buffer %s/%s/%s" (& || &) options[&] options[&])) (refPoint = if(options[&] enterPoint(?prompts &) leGetRefPoint(cv))) (transform = list(mapcar(minus refPoint) "R0" 1.0)) ... )

    funcall((abCopyPaste->copy))

    ERROR 

     

     

    • Post Points: 20
  • Thu, Sep 17 2009 8:00 AM

    Re: Is it possible to have a "Copy and Paste" function like the "Yank and Paste" ? Reply

    Are you using IC5141 or IC613? I've not tested the code with IC5141, but a quick scan before I posted it led me to believe it would be OK.

    Where there any particular kinds of things you had selected?

    Anyway, I'll take a look.

    Regards,

    Andrew.

    • Post Points: 20
  • Thu, Sep 17 2009 8:20 AM

    Re: Is it possible to have a "Copy and Paste" function like the "Yank and Paste" ? Reply

    our cadence version  is - cadence 5.10.41.500.6.137

    here what i did:

    - i tried ctrl+6, to copy and selected a wire

    - then alt+6, to paste... it says, point destination location, but nothing happened

     

    2nd try,

    - i selected a wire, then ctrl+6 and get the errors i posted earlier.

    - then alt+6, same thing, nothing happened.

     

    i think i need to creat this folder, right? ---->lib/copyBuffer/copyBuffer.

     

    • Post Points: 20
  • Thu, Sep 17 2009 8:36 AM

    Re: Is it possible to have a "Copy and Paste" function like the "Yank and Paste" ? Reply

    What it should do is put the copyBuffer into the library for the same cell you're editing - so you shouldn't need to change it.

    Perhaps the problem is that there is no reference point. The default is that it doesn't prompt, but picks it up from the reference point (set with the plus bindkey).

    You might want to do:

    abCopyPaste->setOption('promptRefPoint t)

    And then that problem will be cured. I'm going to fix the code to handle this scenario, as well as fix another issue with the code I just spotted (if you try to set promptRefPoint back to nil, it will fail).

    But I think the above setting (which you could put in your .cdsinit after loading the code) will fix your problem. I'll paste the improved code back here when I'm done (out of the office at the moment, so won't be right now). Sorry - insufficient testing when I threw this together in the first place...

    Regards,

    Andrew.

    • Post Points: 20
  • Thu, Sep 17 2009 9:02 AM

    Re: Is it possible to have a "Copy and Paste" function like the "Yank and Paste" ? Reply

    Hi Andrew,

    adding abCopyPaste->setOption('promptRefPoint t) does the trick.

    i'll wait for your revision.

     

    Thanks! 

     

     

    • Post Points: 20
  • Thu, Sep 17 2009 3:06 PM

    Re: Is it possible to have a "Copy and Paste" function like the "Yank and Paste" ? Reply

    Here's the revised code. Now if you have promptRefPoint off (the default), it will still prompt you for a reference point if one is not set, so you won't get the stack trace. However, if you're not used to setting a reference point (you can see the current reference point by turning on Options->Editor->Display Reference Point, and the + key on the numeric keypad is normally bound to setting the reference point manually), you'll probably find it easier to continue turning promptRefPoint on as I suggested before.

    /* abCopyPaste.ils
    
    Author     A.D.Beckett
    Group      Custom IC (UK), Cadence Design Systems Ltd.
    Language   SKILL
    Date       Nov 24, 2008 
    Modified   A.D.Beckett
    By         Sep 17, 2009 
    
    A package to copy and paste into a buffer (default lib/copyBuffer/copyBuffer
    where lib is the same library you're working in). Smarter than yank/paste
    
    ; copy into buffer cellView
    abCopyPaste->copy()
    
    ; paste from buffer cellView
    abCopyPaste->paste()
    
    ; without this, the copyBuffer is in the same library as
    ; the cell being edited
    abCopyPaste->setOption('bufferLib "mylib")
    
    ; normally uses the reference point, but can also prompt
    ; for it
    abCopyPaste->setOption('promptRefPoint t)
    
    ***************************************************
    
    SCCS Info: @(#) abCopyPaste.ils 09/17/09.22:09:31 1.2
    
    */
    
    (importSkillVar abCopyPaste)
    (setq abCopyPaste
          (let (
    	    (options (makeTable 'options nil))
    	    (optionNames '(bufferLib bufferCell bufferView 
    				     promptRefPoint))
    	    )
    	/***************************************************************
    	*                                                              *
    	*                (setOption option value "sg")                 *
    	*                                                              *
    	*  Exported function for setting an option for the copy/paste  *
    	*    package. Needs the name of the option and a value. The    *
    	*     name is checked to ensure it is a valid option name.     *
    	*                                                              *
    	***************************************************************/
    	(defun setOption (option value "sg")
    	  (if (memq option optionNames)
    	    (setarray options option 
    		      (if (listp value) (copy value) value)
    		      )
    	    (error "Unrecognised option %L - must be one of %L\n"
    		   option optionNames)
    	    )
    	  ) ; defun setOption
    	/***************************************************************
    	*                                                              *
    	*                 (getOption @optional option)                 *
    	*                                                              *
    	*  Exported function for getting the value of an option or a   *
    	*               list of the legal option names.                *
    	*                                                              *
    	***************************************************************/
    	(defun getOption (@optional option)
    	  (if option
    	    (if (memq option optionNames)
    	      (arrayref options option)
    	      (error "Unrecognised option %L - must be one of %L\n"
    		     option optionNames)
    	      )
    	    (sort (copy optionNames) 'alphalessp)
    	    )
    	  ) ; defun getOption
    	/***************************************************************
    	*                                                              *
    	*                      (copyToBuf [cv])                        *
    	*                                                              *
    	*   Exported function to copy selected objects into a buffer   *
    	*                                                              *
    	***************************************************************/
    	(defun copyToBuf (@optional (cv (geGetEditCellView)))
    	  (let (buffer refPoint transform)
    	    (setq buffer 
    		  (dbOpenCellViewByType
    		    (or (arrayref options 'bufferLib)
    			(getq cv libName))
    		    (arrayref options 'bufferCell)
    		    (arrayref options 'bufferView)
    		    "maskLayout"
    		    "w"
    		    ))
    	    (unless buffer
    	      (error "Could not create copy buffer %s/%s/%s"
    		     (or (arrayref options 'bufferLib)
    			 (getq cv libName))
    		     (arrayref options 'bufferCell)
    		     (arrayref options 'bufferView)
    		     ))
    	    (setq refPoint
    		  (if (or (arrayref options 'promptRefPoint)
    			  (null (leGetRefPoint cv)))
    		    (enterPoint ?prompts 
    				(list "Point at the reference point for the copy:"))
    		    (leGetRefPoint cv)))
    	    (leSetRefPoint cv refPoint)
    	    (setq transform
    		  (list (mapcar minus refPoint) "R0" 1.0))
    	    (foreach fig (geGetSelectedSet cv)
    		     (dbCopyFig fig buffer transform)
    		     )
    	    (dbSave buffer)
    	    (dbClose buffer)
    	    )
    	  )
    	/***************************************************************
    	*                                                              *
    	*                           (paste)                            *
    	*                                                              *
    	* Exported function to paste buffer into cellView at prompted  *
    	*                            point                             *
    	*                                                              *
    	***************************************************************/
    	(defun paste ()
    	  (enterPoint ?prompts (list "Point at destination location:")
    		      ?doneProc "abCopyPaste->pasteDone"
    		      )
    	  t
    	  )
    	/***************************************************************
    	*                                                              *
    	*                 (pasteDone wid done points)                  *
    	*                                                              *
    	*   Exported function (used by enterFunction in (paste)) to    *
    	*                   actually do the pasting.                   *
    	*                                                              *
    	***************************************************************/
    	(defun pasteDone (wid done points)
    	  (let (transform cv buffer)
    	    (when done
    	      (setq transform (list (car points) "R0" 1.0))
    	      (setq cv (geGetEditCellView wid))
    	      (setq buffer (dbOpenCellViewByType
    			     (or (arrayref options 'bufferLib)
    				 (getq cv libName))
    			     (arrayref options 'bufferCell)
    			     (arrayref options 'bufferView)
    			     "maskLayout"
    			     "r"
    			     ))
    	      (if buffer
    		(progn
    		  (foreach objs 
    			   (list
    			     (getSGq buffer shapes)
    			     (getSGq buffer instances)
    			     (getSGq buffer vias)
    			     (getSGq buffer figGroups)
    			     (getSGq buffer mosaics)
    			     (getSGq buffer blockages)
    			     (getSGq buffer rows)
    			     (getSGq buffer markers)
    			     (getSGq buffer areaBoundaries)
    			     (getSGq buffer guides)
    			     (getSGq buffer routes)
    			     (getSGq buffer steiners)
    			     )
    			   (foreach fig objs
    				    (dbCopyFig fig cv transform)
    				    ) ; foreach fig
    			   ) ; foreach objs
    		  (dbClose buffer)
    		  )
    		(warn "Could not open copy buffer %s/%s/%s"
    		      (or (arrayref options 'bufferLib)
    			  (getq cv libName))
    		      (arrayref options 'bufferCell)
    		      (arrayref options 'bufferView)
    		      )
    		)
    	      t
    	      ) ; when
    	    ) ; let
    	  ) ; defun pasteDone
    	;----------------------------------------------------------------
    	; Defaults
    	;----------------------------------------------------------------
    	(setarray options 'bufferLib nil)
    	(setarray options 'bufferCell "copyBuffer")
    	(setarray options 'bufferView "copyBuffer")
    	;----------------------------------------------------------------
    	; The DPL containing all the exported functions for the
    	; package
    	;----------------------------------------------------------------
    	(list nil
    	  'setOption setOption
    	  'getOption getOption
    	  'copy copyToBuf
    	  'paste paste
    	  'pasteDone pasteDone
    	  ) ; list
    	) ; let
          ) ; setq abCopyPaste
    

    Best Regards,

    Andrew.

    • Post Points: 5
Page 1 of 1 (10 items)
Sort Posts:
Started by zeroskills at 16 Sep 2009 03:01 PM. Topic has 9 replies.