Macro help need

Macro help need

hrh46
Advocate Advocate
379 Views
2 Replies
Message 1 of 3

Macro help need

hrh46
Advocate
Advocate

I need comparing start points of toolpath segments (centrr drill holes) to delete duplicate segments. Is there anyone who know how can I get start point parameters(x,y,z)?

0 Likes
Accepted solutions (1)
380 Views
2 Replies
Replies (2)
Message 2 of 3

ondrej.mikulec
Advocate
Advocate
Accepted solution

Hi,

try this macro.

ENTITY $ent = $entity('Toolpath','')
IF $ent.Strategy == "drill" {

	OBJECT LIST $startPoints = {}

	INT $segmentsCount = $toolpath_component_count($ent, 'segments')

	WHILE $segmentsCount > 0 {

		$segmentsCount = $segmentsCount - 1
		REAL $sgmPointCount = $segment_point_count( $ent, $segmentsCount)

		IF $sgmPointCount > 1 {
		
			OBJECT $pntStart = segment_get_point( $ent, $segmentsCount, 0)
			
			BOOL $matchStart = 0
			
			FOREACH $obj IN $startPoints {
				IF $round($obj.Position.X,3) == $round($pntStart.Position.X,3) AND $round($obj.Position.Y,3) == $round($pntStart.Position.Y,3) AND $round($obj.Position.Z,3) == $round($pntStart.Position.Z,3) {
					$matchStart = 1
					BREAK
				}
			}
			
			IF $matchStart {
				EDIT TPSELECT ; TPLIST UPDATE\r $segmentsCount NEW
				DELETE TOOLPATH ; SELECTED
			} ELSE {
				INT $i = $add_last($startPoints, $pntStart)
			}

		}
	}
}

 

0 Likes
Message 3 of 3

hrh46
Advocate
Advocate

Very Good! Just What I expected. many thanks .

0 Likes