Community
PowerMill Forum
Welcome to Autodesk’s PowerMill Forums. Share your knowledge, ask questions, and explore popular PowerMill topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Select Surfaces Z0

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Felipe_Callegario
222 Views, 2 Replies

Select Surfaces Z0

Hello, I need a macro to select the surfaces that are in Z0. Thanks in advance

2 REPLIES 2
Message 2 of 3

FUNCTION main() {
	GRAPHICS LOCK
	BLANK UNDO
	EDIT MODEL ALL DESELECT ALL
	EDIT MODEL ALL SELECT FLAT
	INT $Count = 0
	FOREACH $Mod IN FOLDER("Model") {
		$Count =  $Count + number_selected($Mod)
	}
	IF $Count > 0 {
		STRING LIST surfs = {}
		CALL GetFlatFacesName($surfs)
		UNDRAW BLOCK
		EDIT BLOCKTYPE BOX
		EDIT BLOCK COORDINATE WORKPLANE
		EDIT BLOCK ALL UNLOCK
		EDIT BLOCK TOLERANCE "0.01"
		EDIT BLOCK RESETLIMIT "0"
		EDIT BLOCK LIMITTYPE MODEL
		STRING LIST surfs_z0 = {}
		FOREACH surf IN $surfs {
			EDIT MODEL ALL DESELECT ALL
			STRING $face = RTRIM($surf)
			EDIT MODEL ALL SELECT $face
			EDIT BLOCK RESET
			IF ABS(ROUND($Block.Limits.ZMin,3)) <= 0.01 {
				INT add = ADD_LAST($surfs_z0, $face)
			}
		}
		EDIT MODEL ALL DESELECT ALL
		IF SIZE($surfs_z0) == 0 {
			GRAPHICS UNLOCK
			MESSAGE WARN "No flat surfaces found at Z0."
			MACRO ABORT
		}
		FOREACH surf IN $surfs_z0 {
			EDIT MODEL ALL SELECT $surf
		}
	} ELSE {
		MESSAGE WARN "No flat surfaces found."
	}
	GRAPHICS UNLOCK
}

FUNCTION GetFlatFacesName(OUTPUT STRING LIST Surf) {
	STRING $TraceFilePath = MACRO_PATH(false) + "\Surflist.txt"
	$Surf = {}
	ECHO OFF DCPDEBUG UNTRACE COMMAND ACCEPT
	TRACEFILE OPEN $TraceFilePath
	PRINT SELSURFACE
	TRACEFILE CLOSE

	FILE OPEN $TraceFilePath FOR READ AS Input
	FILE READ $Surf FROM Input
	FILE CLOSE Input
	DELETE FILE $TraceFilePath

	INT Ret = REMOVE_FIRST($Surf)
}

Rafael Sansão

EESignature

Message 3 of 3

Excellent, that's exactly what I wanted

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report