Jump to content
Sign in to follow this  
andyer

setting the status of a block/Superblock programmatically

Recommended Posts

O learned denizens of the Activate forum,

 

Is there a way to set the status of a block (Superblock in this case) programmatically?   (e.g. to do this via GUI, right click on a block to select Status --> On/Off).  I would like to control the topology of my model via some scripting if possible and wondering if I can do this by controlling the status (or if you have another suggestion I'm open to it, too).

 

Cheers,

 

Andy

Share this post


Link to post
Share on other sites

Looks like I figured it out with some trial and error.  If the name of my block is 'SuperBlock', then you can do this with the following commands which deactivate (status = off) or activate, respectively:

 

> bdeSetBlockStatus(bdeGetBlockByFullName('SuperBlock'), 'off')

> bdeSetBlockStatus(bdeGetBlockByFullName('SuperBlock'), 'on')

Share this post


Link to post
Share on other sites

Here's a couple of commands to help you get the Full name of blocks:

 

First, select the block you want by clicking on it.  Then in the command window, use:

 

blk=bdeGetSelectedBlock(bdeGetCurrentDiagram)

 

bdeGetBlockFullName(blk)

 

Voila!

Share this post


Link to post
Share on other sites

So, it turns out that this command bdeSetBlockStatus () does not work on the current simulation (needs to be fixed).  However, a colleague and I (thanks Liv!) were discussing this and he showed me that I can achieve the same behavior by using an Include block on Activate.  What you do is to put the superblocks you want to use in your model with Status = off.  Then use an include block to select which one you want to use and the Include block will automagically turn the Status = on to the one selected.  You can use the commands below to get the name of the model so you can self-reference to the path required in the Include block, e.g.:

 

model_path=bdeGetModelFilePath(bdeGetCurrentModel());
[current_dir,model_name,model_ext]=fileparts(model_path);
model_nameTotal=[model_name,model_ext]; %<--- put this as the name of the "Model path"  in the Include block so you can self reference in case you change the name of your model

 

Happy simulating, and thanks again, Liv!

 

Cheers,

 

Andy

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...