Check for Active Boundary

Check for Active Boundary

slejeuneSZHJV
Contributor Contributor
860 Views
7 Replies
Message 1 of 8

Check for Active Boundary

slejeuneSZHJV
Contributor
Contributor

I am having some trouble getting this macro to work,

What I am trying to do is, check to see if "BOUNDARY_3" is active, and if it is do ect... ELSE do etc..

 

I started with this code below and it works as it should.

 

IF entity_exists('boundary', 'BOUNDARY_3') {
do etc...
} ELSE {
do etc...
}

 

Here is where I switched it up to have it check if it was active and I'm having no luck getting it to work.

 

IF active entity_exists('boundary', 'BOUNDARY_3') {
do etc...
} ELSE {
do etc...
}

 

Any suggestions would be appreciated!

Thank you!

 

0 Likes
Accepted solutions (2)
861 Views
7 Replies
Replies (7)
Message 2 of 8

cfastNJWK6
Advisor
Advisor

You can get the Active Boundary like this:

STRING $ActiveBoundary = ""
$ActiveBoundary = entity_exists(entity('Boundary', ''))
0 Likes
Message 3 of 8

rafael.sansao
Advisor
Advisor
IF entity_exists('boundary', '') AND entity_exists('boundary', 'BOUNDARY_3') {
	do etc...
} ELSE {
	do etc...
}

Rafael Sansão

OptiNC - www.optinc.tech

EESignature

0 Likes
Message 4 of 8

slejeuneSZHJV
Contributor
Contributor

@cfastNJWK6 @rafael.sansao 

Thank you! , I gave both a try and seem to get the same results. 

I do have two other boundaries Im working with,  Boundary_1 , Boundary_2 , and Boundary_3 are in this part.

 

The only thing I am having issues with is,

If none of the boundaries are active it does the ELSE section of the code, and if any one of these boundaries are active it does the first section of the code , regardless of what the name of the boundary is. When it needs to be checking if the Boundary_3 is active or not. 

 

 

 

0 Likes
Message 5 of 8

rafael.sansao
Advisor
Advisor
Accepted solution

Try:

IF entity_exists('boundary', '') {
	IF $entity('boundary', '').Name == 'BOUNDARY_3' {
		MESSAGE INFO "BOUNDARY_3 Active"
	} ELSE {
		MESSAGE INFO "Other"
	}
}

Rafael Sansão

OptiNC - www.optinc.tech

EESignature

0 Likes
Message 6 of 8

slejeuneSZHJV
Contributor
Contributor

@rafael.sansao   This worked perfect 

Thank you!

0 Likes
Message 7 of 8

cfastNJWK6
Advisor
Advisor
Accepted solution

I typically don't like to hard-code entity names into my macros.  To avoid it you can do something like this to allow the user to select which boundary to use while the macro runs:

STRING $ActiveBoundary = ""
$ActiveBoundary = INPUT ENTITY BOUNDARY "Select the Boundary you would like to use."
0 Likes
Message 8 of 8

slejeuneSZHJV
Contributor
Contributor

@cfastNJWK6 , I will give it a try and see how things go, there are some applications where this will be very helpful. Thanks! 

0 Likes