Delete bottom part of boundary automatically?

Delete bottom part of boundary automatically?

johnc4668
Advocate Advocate
424 Views
5 Replies
Message 1 of 6

Delete bottom part of boundary automatically?

johnc4668
Advocate
Advocate

Fellas,

Looking for a way to delete this bottom section of boundary automatically with no user intervention using colors and a user boundary. I want to select the color on the inside of this pocket or pockets and just use the top section. 

 

johnc4668_0-1701795373425.png

 

 

 

0 Likes
Accepted solutions (1)
425 Views
5 Replies
Replies (5)
Message 2 of 6

ondrej.mikulec
Advocate
Advocate

Hi,

try this:

FUNCTION Main() {
	ENTITY $bound = entity('Boundary','')

	INT $count = segments($bound)
	INT $targetIndex = -1
	REAL $targetZMax = 0

	WHILE $count > 0 {
		$count = $count -1

		EDIT BOUNDARY ; DESELECT ALL
		EDIT BOUNDARY ; SELECT $count
		
		REAL $zMAx = 0
		CALL GetZMax($zMAx)
		IF $zMAx > $targetZMax {
			$targetIndex = $count
			$targetZMax = zMAx
		}
	}

	IF $targetIndex > -1 {

		$count = segments($bound)

		WHILE $count > 0 {
			$count = $count -1
			
			IF $count != $targetIndex {
				EDIT BOUNDARY ; DESELECT ALL
				EDIT BOUNDARY ; SELECT $count
				DELETE BOUNDARY ; SELECTED
			}

		}

	}
}

FUNCTION GetZMax(OUTPUT REAL $zMAx) {
	
	EDIT BLOCKTYPE BOX
	EDIT BLOCK COORDINATE WORKPLANE
	EDIT BLOCK ALL UNLOCK
	EDIT BLOCK LIMITTYPE BOUNDARY
	EDIT BLOCK RESET
	EDIT BLOCK LIMITTYPE MODEL
	
	$zMAx = $Block.Limits.ZMax

}

Message 3 of 6

nguyenthinhvt95
Advocate
Advocate

@johnc4668 

I would like to suggest a macro code to get the top section. Hope this's work.

 

ENTITY $bound = entity('Boundary','')
INT $count = segments($bound)
INT $i = 1 
 
EDIT BOUNDARY $bound.name CURVEEDITOR START
CURVEEDITOR REORDER SORT STARTZ
WHILE $i  < $count {
CURVEEDITOR REORDER LISTUPDATE\r 0 NEW
CURVEEDITOR DELETE SELECTED
$i = $i + 1
}
CURVEEDITOR FINISH ACCEPT
 
 
 

 

Message 4 of 6

johnc4668
Advocate
Advocate

@nguyenthinhvt95 

 

This worked great! But it wants to delete every boundary except one. Im looking to keep all the boundaries at the top surface and delete anything below the top or below z zero. 

 

Before:

johnc4668_0-1701866424508.png

 

 

After:

 

johnc4668_1-1701866755311.png

 

0 Likes
Message 5 of 6

ondrej.mikulec
Advocate
Advocate
Accepted solution

I changed things to:
The first loop finds the highest ZMax.
The second loop removes what's not in ZMax and keeps all that is.
The third loop goes through each segment, copying the boundaries for each one.

FUNCTION Main() {
	ENTITY $bound = entity('Boundary','')

	INT $count = segments($bound)
	REAL $targetZMax = 0

	WHILE $count > 0 {
		$count = $count -1

		EDIT BOUNDARY ; DESELECT ALL
		EDIT BOUNDARY ; SELECT $count
		
		REAL $zMAx = 0
		CALL GetZMax($zMAx)
		IF $round($zMAx,3) > $round($targetZMax,3) {
			$targetZMax = zMAx
		}
	}



	$count = segments($bound)

	WHILE $count > 0 {
		$count = $count -1
		
		EDIT BOUNDARY ; DESELECT ALL
		EDIT BOUNDARY ; SELECT $count
		
		REAL $zMAx = 0
		CALL GetZMax($zMAx)
		IF $round($zMAx,3) != $round($targetZMax,3) {
			EDIT BOUNDARY ; DESELECT ALL
			EDIT BOUNDARY ; SELECT $count
			DELETE BOUNDARY ; SELECTED
		}

	}


	
	$count = segments($bound)
	
	WHILE $count > 0 {
		$count = $count -1

		EDIT BOUNDARY ; DESELECT ALL
		EDIT BOUNDARY ; SELECT $count
		COPY BOUNDARY ; SELECTED
	}
}

FUNCTION GetZMax(OUTPUT REAL $zMAx) {
	
	EDIT BLOCKTYPE BOX
	EDIT BLOCK COORDINATE WORKPLANE
	EDIT BLOCK ALL UNLOCK
	EDIT BLOCK LIMITTYPE BOUNDARY
	EDIT BLOCK RESET
	EDIT BLOCK LIMITTYPE MODEL
	
	$zMAx = $Block.Limits.ZMax

}

 

Message 6 of 6

johnc4668
Advocate
Advocate
I owe you a beer for this! thank you!! I'll take it from here!
0 Likes