[Gmsh] Can you delete the variables created in the GUI menu?

Marco Antolovic marco_antolovic at yahoo.it
Fri Nov 6 19:19:48 CET 2020


 Hi Christophe,
thanks for the answer, that's exactly what I was looking for.
I've tried to use the Visible parameter before but could not figure out how to implement it but yesterday the penny finally dropped :-)
Regards,
Marco
PS: If someone is interested below is an example of how you could do it

// Set the number of maximum dielectric groups//============================================nr_dielectric_groups_max =10;
// Check the number of dielectric group variables present in ONELAB database// If there is none no action is taken// old_nr_dg represent the nr. of dielect. groups available from previous script run//==================================================================================old_nr_dg=0;For i In {1:nr_dielectric_groups_max}  seekZero = GetNumber(Sprintf(" Dielectric parameters/ Dielectric thickness %g", i));  If (seekZero!=0)    old_nr_dg +=1;  EndIfEndFor
// Define the new nr. of dielect. groups//======================================DefineConstant[ nr_dielectric_groups = {1, Min 1, Max nr_dielectric_groups_max, Step 1, Name " Dielectric parameters/Nr. of dielectric groups"} ];
// Chose which variables will be hidden/shown//===========================================If (old_nr_dg>=nr_dielectric_groups)  nr_count=old_nr_dg;Else  nr_count=nr_dielectric_groups;EndIf
For i In {0:nr_count-1}  visi_flag(i)=0;EndForFor i In {0:nr_dielectric_groups-1}  visi_flag(i)=1;EndFor
// Create variables and update menu view//======================================For i In {0:nr_count-1}  dielectric_thickness(i) = DefineNumber[ 550, Min 1, Max 2000, Step 1, Name Sprintf(" Dielectric parameters/ Dielectric thickness %g", i+1), Visible visi_flag(i) ];  dielectric_thickness(i) = dielectric_thickness(i)/1e6;EndFor
    Il mercoledì 4 novembre 2020, 08:59:12 CET, Christophe Geuzaine <cgeuzaine at uliege.be> ha scritto:  
 
 

> On 30 Oct 2020, at 15:28, Marco Antolovic <marco_antolovic at yahoo.it> wrote:
> 
> Hi all,
> 
> Is there a way to delete a variable that you created in the GUI menu when you reload the script?
> 
> I'll try to explain my question with this example:
> 
>  nr_dielectric_groups = DefineNumber[ 4, Min 1, Max 2000, Step 1, Name " Dielectric parameters/Nr. of dielectric groups" ];
> 
> For i In {0:nr_dielectric_groups-1}
>    dielectric_thickness(i) = DefineNumber[ 550, Min 1, Max 2000, Step 1, Name Sprintf(" Dielectric parameters/ Dielectric thickness %g", i+1) ];
> EndFor
> 
> when you first start the script dielectric_thickness() will be a vector of dimension four and you will see four dielectric_thickness variables in the menu.
> 
> However if I set nr_dielectric_groups=2 the menu will still show four dielectric_thickness variables. Is there a way to delete excess variables from the menu?
> 

You can "undefine" them using "UndefineConstant[]". But in practice we usually simply hide them (with the "Visible" attribute) : this way if you change your mind and later re-increase "nr_dielectric_groups", you will still have the value that you might have selected before.

Christophe



> Many thanks,
> 
> Marco
> 
> 
> _______________________________________________
> gmsh mailing list
> gmsh at onelab.info
> http://onelab.info/mailman/listinfo/gmsh

— 
Prof. Christophe Geuzaine
University of Liege, Electrical Engineering and Computer Science 
http://people.montefiore.ulg.ac.be/geuzaine



  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://onelab.info/pipermail/gmsh/attachments/20201106/283f11a6/attachment.html>


More information about the gmsh mailing list