I’m developing a C++ plugin for Coreform Cubit 2023.8 and I want to create a command that takes a list of volumes as input. I see that CubitCommandData
class has a get_entity_list()
function, but there is no documentation on how to construct the command syntax string to obtain this entity list. Can someone provide some guidance?
Hi @xsj617603321,
you could take a look at this post from @karl.
I personally didn’t accomplish a command syntax that can use the extended selection from cubit with the sdk yet. If you want a command syntax that obtains a list of entities, you could also use keywords and the value type, it could look like this
std::vector<std::string> ccxResultConvertJobCommand::get_syntax()
{
std::vector<std::string> syntax_list;
std::string syntax = "ccx ";
syntax.append("result convert job <value:label='job_id',help='<job_id>'> [partial] ");
syntax.append("[block <value:label='block_ids',help='<block_ids>'>...] " );
syntax.append("[nodeset <value:label='nodeset_ids',help='<nodeset_ids>'>...] " );
syntax.append("[sideset <value:label='sideset_ids',help='<sideset_ids>'>...] " );
syntax_list.push_back(syntax);
return syntax_list;
}
in the execute you could query the values like this
std::vector<int> block_ids;
if (data.find_keyword("BLOCK")){
data.get_values("block_ids", block_ids);
}
for more examples you could take a look at the commands in my opensource calculix component.
Thanks for your answer. I guess this means CubitCommandData::get_entity_list()
is not usable at this moment…
Maybe @kgmerkley knows how it can be used to achieve a parsing for a command. I only got it working if the input are integers, but that was not desirable.
Basically it is more of question how you will call your command. If it’s with the python API the parse_cubit list can be used to get a list of entity id’s for your command. Same can be done in c++ with the cubitinterface and also with the claro framework, when you create your own widgets for the gui.
We only need to get it working with integer indices for volumes, so the solution you pointed out works for us. I was just curious about how to use that particular function. Thank you!
Actually, CommandData is exported as CubitCommandData. It is used in the SDK examples <Coreform Cubit install dir>/examples/CommandPlugin
. In my 2023.11 installation there is documentation for this part of the SDK in the docs/Cubit-SDK folder. Open the index.html in your browser. One way to find the CubitCommandData is to browse to Classes/Class List and look up CubitCommandData. For a list of integer volumes you would do something like
bool MyExportCommand::execute(CubitCommandData &data)
{
std::vector<int> volume_ids;
data.get_values("volume_label", volume_id);
...
}
where the volume id label is defined in the syntax string as shown in the earlier examples.
Is that helpful?
Karl
Coreform Cubit Consulting
karl@coremesh.co
We have the documentation page for CubitCommandData
and got the integer inputs working. Thanks anyway!