Creating a hole featureset based on depth type

Creating a hole featureset based on depth type

iamcdn79
Mentor Mentor
489 Views
8 Replies
Message 1 of 9

Creating a hole featureset based on depth type

iamcdn79
Mentor
Mentor

I have this macro that I created that is supposed to create a separate hole feature set if a depth type of blind exists called EXCLUDED .625 DIA. HOLES BLIND in a hole featureset called EXCLUDED .625 DIA. HOLES.

 

I know it exists but all it does is loop through the featureset but doesn't select the blind hole and create a new feature set. 

 

iamcdn79_0-1696508590429.png

// Check if the EXCLUDED .625 DIA. HOLES feature set exists
  IF entity_exists('featureset','EXCLUDED .625 DIA. HOLES') {
    // Activate the feature set
    ACTIVATE FEATURESET "EXCLUDED .625 DIA. HOLES"
    
    // Select blind holes
    EDIT FEATURESET ; DESELECT ALL
    EDIT SELECTION CLEAR
    EDIT SELECTION FILTER DEPTHTYPE "Blind"
    EDIT SELECTION APPLY
    
   
      // Check if any features were selected
    IF SIZE(components($entity('featureset','EXCLUDED .625 DIA. HOLES'))) > SIZE(components($entity('featureset',''))) {
     // Copy selected features to a new feature set
    COPY FEATURESET ; SELECTED
    RENAME FEATURESET # "EXCLUDED .625 DIA. HOLES BLIND"
  }
  }

Intel Core i9 13900KF CPU
128 GB Kingston Beast DDR4 SDRAM
PNY RTX A2000 6GB Video Card
WD 1 TB SSD Hard Drive
Windows 11 Pro

0 Likes
490 Views
8 Replies
Replies (8)
Message 2 of 9

icse
Collaborator
Collaborator

So you whant to Copy only the 'Blind' Holes from the active featureset in a new one?

Whats your end goal?

 

0 Likes
Message 3 of 9

iamcdn79
Mentor
Mentor

My goal is to create a separate drilling toolpath for that type of diameter.

 

Currently, a .625 diameter is used for a 3/8 SHCS where the counterbore is 5/8 diameter, and also for a 5/8 dowel, I want to separate them to create an individual toolpath not the same toolpath with both of those holes in them.

 

That is the only way I can think of separating them.

 

iamcdn79_0-1696513861277.png

 


Intel Core i9 13900KF CPU
128 GB Kingston Beast DDR4 SDRAM
PNY RTX A2000 6GB Video Card
WD 1 TB SSD Hard Drive
Windows 11 Pro

0 Likes
Message 4 of 9

icse
Collaborator
Collaborator

does this come close?

// Check if the EXCLUDED .625 DIA. HOLES feature set exists
if not entity_exists('featureset','EXCLUDED .625 DIA. HOLES') {
	return
}


ACTIVATE FEATURESET "EXCLUDED .625 DIA. HOLES"

//keep track if the form was open we need to raise the form to get the position of 'blind' in the list
//im not 100% sure if its always on position 0...
bool $isVisible = widget('FeatureSelect').Visible
if not $isVisible {
	FORM FEATURESELECT
}

//clear the selection
EDIT SELECTION CLEAR
EDIT SELECTION TYPE DEPTHTYPE

//get the number of elements in the list
int $n = list_num_rows('FeatureSelect.List')

//loop over each element store the index and exit the loop if we found 'Blind'
int $index = 0
while $index < $n {	
	if list_cell_value('FeatureSelect.List',$index,0) == 'Blind' {
		break
	}
	$index = $index + 1
}

//the if the form was closed to begin with we close the form
if not $isVisible {
	FEATURESELECT CANCEL
}

//if we looped trouhg the whole loop then there was no element with the name 'Blind'
if $index >= $n {
	return
}



// Select blind holes
EDIT FEATURESET ; DESELECT ALL
EDIT SELECTION CLEAR
EDIT SELECTION TYPE DEPTHTYPE
EDIT SELECTION STORE ${index} NEW
EDIT SELECTION ADD EDIT SELECTION APPLY

// Check if any features were selected >>> we do not need this becose we already found 'Blind' in the form before
//just to show you how to check if theres a selected feature
if number_selected($entity('featureset','')) > 0 {

	// Copy selected features to a new feature set
	COPY FEATURESET ; SELECTED
	
	//give the new feature a new name if the original is already taken so the macro does not break
	string $name = "EXCLUDED .625 DIA. HOLES BLIND"
	if entity_exists('featureset', $name) {
		$name = new_entity_name('featureset', $name)
	}
	RENAME FEATURESET # ${name}
}
Message 5 of 9

iamcdn79
Mentor
Mentor

Sort of, it copied all the holes from from the EXCLUDED .625 DIA. HOLES featureset to a new featureset set called 

EXCLUDED .625 DIA. HOLES BLIND instead of just copying the blind type holes

 

 

iamcdn79_0-1696514715734.png

 

 

 


Intel Core i9 13900KF CPU
128 GB Kingston Beast DDR4 SDRAM
PNY RTX A2000 6GB Video Card
WD 1 TB SSD Hard Drive
Windows 11 Pro

0 Likes
Message 6 of 9

icse
Collaborator
Collaborator

You can use those boxes... change bot to 1 and it should compute only the top element

 

pmforum.png

0 Likes
Message 7 of 9

icse
Collaborator
Collaborator

oh my bad i ususally dont work with compound holes...

you need to split em first with this command:

 

 

EDIT FEATURESET ; HOLES EXPLODE

 

 

its also in the contexmenue if you rightklick the featureset => edit => separate compound holes

 

Also the you should rewrite the macro:

  • copy the original featureset completely
  • split compound holes of the copy
  • select all 'Blind' holes
  • invert the selection
  • delete the selection
  • then rename or delete it if its empty

 

so you dont destroy the original featureset

 

0 Likes
Message 8 of 9

iamcdn79
Mentor
Mentor

It puts all those holes as one toolpath which I don't want, I still have to separate those toolpaths between a reamed toopath and a SHCS toolpath 

iamcdn79_0-1696515452552.png

 

That's why I am trying to separate those holes in a featureset and create a toolpath, one for blind, one for through


Intel Core i9 13900KF CPU
128 GB Kingston Beast DDR4 SDRAM
PNY RTX A2000 6GB Video Card
WD 1 TB SSD Hard Drive
Windows 11 Pro

0 Likes
Message 9 of 9

iamcdn79
Mentor
Mentor

I replaced this line 

 

IF SIZE(components($entity('featureset','EXCLUDED .625 DIA. HOLES'))) > SIZE(components($entity('featureset',''))) {

 

with 

 

 if number_selected($entity('featureset','')) > 0 {

 

 

and it worked. Thanks to @icse for that tip.


Intel Core i9 13900KF CPU
128 GB Kingston Beast DDR4 SDRAM
PNY RTX A2000 6GB Video Card
WD 1 TB SSD Hard Drive
Windows 11 Pro