LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to make type-def without making external .ctl file ?

Hi

 

I have the need to create multiple copy enum constant, in which editing any of them will cause changes to all copies, but each of them retain their own selector value.

I know this can be done by type-def. However there are two disadvantages:

 

- I have to change the enum constant a control, disrupting the front panel

- The creation of an additional .ctl file complicates version management.

 

Is it possible to make type-def without making external .ctl file ?

If not, is there any other way to make copies of enum constant ?

 

Thanks in advance !

0 Kudos
Message 1 of 5
(2,687 Views)

@2A91312E wrote:

Is it possible to make type-def without making external .ctl file ?


No.

 


@2A91312E wrote:

If not, is there any other way to make copies of enum constant ?


Put the constant in a VI? Smiley LOL.

 

This will obviously result in the exact same disadvantages as a type def, and then some.

 

I removed pretty much every type def control by switching to OO... There's just much less need from them anymore.

0 Kudos
Message 2 of 5
(2,668 Views)

Maybe you're already aware of this, but:


@2A91312E wrote:

- I have to change the enum constant a control, disrupting the front panel


You can place block diagram constants for an enum defined in a type-def .ctl file without requiring a FP control. The enum on the .ctl file will be a Control, but when you place it, you can drag it directly to the block diagram (or to FP, then right click and choose Change to Constant) to add only a BD constant (with no control disrupting the FP).


GCentral
0 Kudos
Message 3 of 5
(2,658 Views)

@cbutcher wrote:

Maybe you're already aware of this, but:


@2A91312E wrote:

- I have to change the enum constant a control, disrupting the front panel


You can place block diagram constants for an enum defined in a type-def .ctl file without requiring a FP control. The enum on the .ctl file will be a Control, but when you place it, you can drag it directly to the block diagram (or to FP, then right click and choose Change to Constant) to add only a BD constant (with no control disrupting the FP).


Yes, cbutcher is (as always) correct.  Here are the steps I use to make all of my Enums (and other TypeDefs, such as for a large Cluster:

  1. Create the Control (Enum, Cluster, Array, whatever) on a (any) Front Panel.  
    1. If it is an Enum, Edit it and define all its values.
    2. If it is a Cluster, add all of the Cluster Elements and get them in the desired order, with the desired Spacing.
    3. If you don't want certain elements (like Increment/Decrement or Index Display) to be visible, change this now.
  2. If you want the "Control" to be an Indicator, right-click and "Change to Indicator".  You can also do this on the next step.
  3. Right-click and "Make Type Def".  Nothing will appear to change.
  4. Right-click again and choose "Open Type Def".  This takes you to the Control (probably called "Control 1").  Here you have another chance to edit it.  Especially if it is a Cluster, I recommend making an Icon for it.  Why?  A Cluster Constant, if dropped on a Block Diagram, can be huge, but if you right-click it, it will be replaced by its Icon, which will be a "generic Cluster Icon" unless you create your own Custom Icon (which can be a Text Icon saying "My Special Cluster").
  5. When you are done, click File, Save As, and save your TypeDef using a name you'll remember, and in a location within your Project File.
  6. This should bring you back to your original Front Panel, with your (now Custom) control on the Front Panel.
  7. Delete the Front Panel Control!  If you ever need it back (on, say, a Block Diagram), right-click, go to "Select a VI" (or "Select a Control" if on the Front Panel), navigate to the Control, and choose it.  It will appear on the Block Diagram as a Constant (so "invisible" on the Front Panel), and on the Front Panel (if that's where you asked for it) as a Control or Indicator, however you saved it.

Bob Schor

 

0 Kudos
Message 4 of 5
(2,649 Views)

I use almost exactly the same process. I'll just add a couple of minor observations on my workflow.

 

~3b or 4b. This "Control 1.ctl" (or similarly named file) will be by default created at the top level in your project (lvproj) file. This can be annoying, if you're creating it for use in a library (lvlib file). Since libraries can have custom icon borders defined (don't add the 32x32 box here, only the banner...), if you follow this method your icon won't contain that by default. An alternative (only in the case that you want your typedef to be a part of a class or library with a custom icon) is to create the control there (still called "Control 1.ctl", but now a member of the class/library with the class/library icon) and then copy-paste your new control/indicator from step 2 into the new file.

The downside is that this WILL NOT update the control that you copy it from. As a result, you'll need to replace the control or indicator, if you aren't later going to delete it (e.g. in step 7).

 

7b. When adding it in other places, you can also drag from the project window, or use the Quick-Drop (Ctrl-Space) menu. If you have many ctl files with similar names, this might be less than totally useful, although the quick-drop menu, at least since 2017, does list additional information about the location in the project alongside the name of the item to be dropped.

 

typedefs.png

Don't ask me why "Sound and Vibration" comes up with a search for "awesome"...


GCentral
0 Kudos
Message 5 of 5
(2,643 Views)