I am using a skill function to redefine my X and Y snap spacings - because using "e" and filling in the form is too cumbersome!
So, I define the variables xsnap and ysnap, and then:
hiGetCurrentWindow()~>xSnapSpacing = int( xsnap ) hiGetCurrentWindow()~>ySnapSpacing = int( ysnap )
Using skill, is there a better way?
I believe this is the best way. Are you experiencing a problem with this approach?
I typically set several bindkeys to switch between different common snap settings. Here is some example skill. Note, this sets the x and y snap spacings to be the same...
hiSetBindKey("Layout" "<Key>1" "jmSetSnapSpacing(envGetVal( \"layout\" \"xSnapSpacing\"))" ) ;;<-- restore default snap spacing hiSetBindKey("Layout" "<Key>2" "jmSetSnapSpacing(0.25)" ) hiSetBindKey("Layout" "<Key>3" "jmSetSnapSpacing(0.5)" ) hiSetBindKey("Layout" "<Key>4" "jmSetSnapSpacing(1.0)" ) hiSetBindKey("Layout" "<Key>5" "jmSetSnapSpacing(5.0)" ) hiSetBindKey("Layout" "<Key>6" "jmSetSnapSpacing(10.0)" )
procedure( jmSetSnapSpacing( snap @optional window "ng" ) unless( window window = hiGetCurrentWindow() ) window->xSnapSpacing = snap window->ySnapSpacing = snap
Thanks, Jim. I was having other issues in Cadence and they somewhat pointed to this skill script. So, I was curious to learn if there was a better way to perform this task. There still could be other issues with the skill script, however, this does put this item to rest.
Hi John and Jim,
Very late response, however, your hiGetCurrentWindow() did the trick for me. I needed that to write a small piece of code to quickly toggle between 2 grid settings (toggle between fine and coarse grid, which can be set on the fly...). This is my code:
;;; Include the following in the cdsinit file or the file where you set all bind keys:hiSetBindKey( "Layout" "Ctrl<Key>G" "LAYEDIT_ToggleFineCoarseGrid( hiGetCurrentWindow() )")hiSetBindKey( "Layout" "Ctrl Shift<Key>G" "LAYEDIT_ToggleFineCoarseGridForm()");;; Or use any other bindkey combination that suits you...;;; The following global variables must be set as well:dbGrid = 0.01LAYEDIT_FineSnapGrid = dbGridLAYEDIT_CoarseSnapGrid = 10.0procedure( LAYEDIT_ToggleFineCoarseGrid( windowId ) let( ( ( currentGrid 0.01 ) ( newGrid 10.0 ) ( windowNumber 1 ) ) unless( windowId windowId = hiGetCurrentWindow() ) ;;; end of unless currentGrid = windowId~>xSnapSpacing newGrid = LAYEDIT_FineSnapGrid windowNumber = cadr( parseString( sprintf( nil "%L" windowId ) ":" ) ) when( currentGrid == newGrid newGrid = LAYEDIT_CoarseSnapGrid ) ;;; end of when when( newGrid hiGetCurrentWindow()~>xSnapSpacing = newGrid hiGetCurrentWindow()~>ySnapSpacing = newGrid printf( "Layout editor window %s snap grid set to %L.\n" windowNumber newGrid ) ) ;;; end of when ) ;;; end of let) ;;; end of procedure LAYEDIT_ToggleFineCoarseGridprocedure( LAYEDIT_ToggleFineCoarseGridForm() let( ( fineSnapGridField coarseSnapGridField formFieldList LAYEDIT_ToggleFineCoarseGridForm ) ;;;;;;;;;;;;;;;;;;;;;; ;;; Creating the form-fields... fineSnapGridField = hiCreateFloatField( ?name 'fineSnapGridField ?prompt "Fine Snap Grid (um):" ?value LAYEDIT_FineSnapGrid ?defValue LAYEDIT_FineSnapGrid ?callback "LAYEDIT_ToggleFineCoarseGridFormCB( 'fine )" ?acceptNil nil ?editable t ?enabled t ?invisible nil ) coarseSnapGridField = hiCreateFloatField( ?name 'coarseSnapGridField ?prompt "Coarse Snap Grid (um):" ?value LAYEDIT_CoarseSnapGrid ?defValue LAYEDIT_CoarseSnapGrid ?callback "LAYEDIT_ToggleFineCoarseGridFormCB( 'coarse )" ?acceptNil nil ?editable t ?enabled t ?invisible nil ) ;;;;;;;;;;;;;;;;;;;;;; ;;; Constructing the list of form-fields... formFieldList = list( list( fineSnapGridField 0:0 300:35 200 ) list( coarseSnapGridField 0:35 300:35 200 ) ) ;;; end of field-list ;;;;;;;;;;;;;;;;;;;;;; ;;; Creating the form LAYEDIT_ToggleFineCoarseGridForm = hiCreateAppForm( ?name 'LAYEDIT_ToggleFineCoarseGridForm ?formTitle "Set Layout Editor Snap Grid" ?callback "LAYEDIT_ToggleFineCoarseGridFormCB( 'okApply )" ?fields formFieldList ?buttonLayout list( 'OKCancelApply ) ;;; end of ?buttonLayout ?buttonDisabled list( 'Help ) ?unmapAfterCB t ?initialSize 400:100 ) ;;; end hiCreateAppForm ;;;;;;;;;;;;;;;;;;;;;; ;;; Displaying the form ;;; The -1:-1 centres the form around the current mouse pointer location hiDisplayForm( LAYEDIT_ToggleFineCoarseGridForm -1:-1 ) ) ;;; end of let) ;;; end of procedure LAYEDIT_ToggleFineCoarseGridFormprocedure( LAYEDIT_ToggleFineCoarseGridFormCB( switch ) let( ( ) ;;; The value entered in the fields for coarse and fine must not be smaller than the database grid. ;;; That is being checked here, and when the OK or APPLY button is pressed, ;;; the entered values must be stored in the global variables case( switch ( 'fine when( LAYEDIT_ToggleFineCoarseGridForm->fineSnapGridField->value < dbGrid LAYEDIT_ToggleFineCoarseGridForm->fineSnapGridField->value = dbGrid ) ;;; end of when ) ( 'coarse when( LAYEDIT_ToggleFineCoarseGridForm->coarseSnapGridField->value < dbGrid LAYEDIT_ToggleFineCoarseGridForm->coarseSnapGridField->value = dbGrid ) ;;; end of when ) ( 'okApply LAYEDIT_FineSnapGrid = LAYEDIT_ToggleFineCoarseGridForm->fineSnapGridField->value LAYEDIT_CoarseSnapGrid = LAYEDIT_ToggleFineCoarseGridForm->coarseSnapGridField->value ) ) ;;; end of case switch ) ;;; end of let) ;;; end of procedure LAYEDIT_ToggleFineCoarseGridFormCB
I hope this is of any halp to anyone.
edit: changed "le" in procedure/variable name to "LAYEDIT_" per request of Andrew (see below).
I would strongly recommend that you change the prefix used in your code. The general suggestion is that customers use code with an uppercase prefix to avoid clashing with anything that Cadence writes. In your case you've used the "le" prefix which is reserved for the layout editor - if we were to write functions with the same name because we assume they're using our prefix, you'd have a problem.
Also, it's misleading - anyone who sees this code will assume it came from Cadence.
Perhaps you wouldn't mind correcting that and editing your previous post to update the code?
You're absolutely right, sorry, my sincere apologies.
I have changed the code on our systems, however, I am unable to change the code here on the forum. Is it possible for me to edit the code in the original post?
Once again, sorry for this mistake.
With kind regards,
edit: found the edit button, code changed.