How can I check the existence of block by command?

How can I check the existence of block by command?

ikims1126
Contributor Contributor
194 Views
1 Reply
Message 1 of 2

How can I check the existence of block by command?

ikims1126
Contributor
Contributor

Hello.

 

I'm making a macro program.

 

This function needs a block and if there's no block, the function doesn't work and block form pops.

 

So, I want to put in a command which checks the existence of block before main commands.

 

But I couldn't find the command or parameter.

 

Eventually, I check the type of the block and check its scalar parameters.

 

For example, if the type is 'box' then check X, Y and Z lengths are larger than 0 or not. 

 

But I think this way is bizarre and not clean.

 

If there is a way to check the existence of block more cleaner, please let me know.

 

I would be glad if you reply.

Thank you.

0 Likes
195 Views
1 Reply
Reply (1)
Message 2 of 2

kevin.hammond3WX4X
Advocate
Advocate

Try this........

string BLK_TYPE = ""
$BLK_TYPE = block.type
 
REAL $X_range = $block.Limits.Xmax - $block.Limits.Xmin
REAL $Y_range = $block.Limits.Ymax - $block.Limits.Ymin
REAL $Z_range =  $block.Limits.Zmax - $block.Limits.Zmin
IF ($X_range == 0) {
IF ($Y_range == 0) {
IF ($Z_range == 0) {
}
}
Message warn "No block exists"
} ELSE {
message info $block.type
}

 

macro attached below, change .txt to .mac