Submodels in smile

The engine.
Post Reply
mase
Posts: 1
Joined: Sat Feb 22, 2014 9:18 am

Submodels in smile

Post by mase »

Hello,

I would like to see some sample code for creating submodels in smile.
I haven't been successful so far. Thanks.
shooltz[BayesFusion]
Site Admin
Posts: 1417
Joined: Mon Nov 26, 2007 5:51 pm

Re: Submodels in smile

Post by shooltz[BayesFusion] »

Try this:

Code: Select all

int hSub = net.GetSubmodelHandler().CreateSubmodel(DSL_MAIN_SUBMODEL, "sub1");
int hNode = net.AddNode(DSL_CPT, "x1");
DSL_node *node = net.GetNode(hNode);
node->SetSubmodel(hSub);
jdtoellner
Posts: 71
Joined: Mon Aug 01, 2016 9:45 pm

Re: Submodels in smile

Post by jdtoellner »

If I wanted to change the position of the submodel node would I do it this way?

Code: Select all

net.GetSubmodelHandler().GetSubmodel(hSub)->windowpos.center_X = 100;
net.GetSubmodelHandler().GetSubmodel(hSub)->windowpos.center_Y = 100;
(I tried this and it didn't appear to work.)
shooltz[BayesFusion]
Site Admin
Posts: 1417
Joined: Mon Nov 26, 2007 5:51 pm

Re: Submodels in smile

Post by shooltz[BayesFusion] »

The windowpos member represents the location of the submodel window (the MDI child in GeNIe). To move the submodel icon within its parent sub model, use this:

Code: Select all

net.GetSubmodelHandler().GetSubmodel(hSub)->info.position.center_X = 100;
Post Reply