How can i get hole feature set xyz locations?

johnc4668
Advocate
Advocate

How can i get hole feature set xyz locations?

johnc4668
Advocate
Advocate

Fellas,

 

Looking for a clean way to get xyz locations for certain hole feature sets. Sometimes i need to create holes from points for wire edm start holes. Our Wire edm guy needs those locations. Is there a way to get these fast? thanks!

0 Likes
Reply
Accepted solutions (1)
1,208 Views
12 Replies
Replies (12)

cfastNJWK6
Advisor
Advisor

There are a lot of different ways to do this.  If you already have a featureset, I would just write a drilling program and post it out (make sure to have drilling cycles turned on).  If you are looking for a macro solution, it would be possible to export a file with locations from a point (pattern), or from a hole featureset.  It just depends on exactly what you are looking for.  Do you want to export the locations to a  txt or csv file? Or just show the XYZ positions on screen?

johnc4668
Advocate
Advocate

@cfastNJWK6 Exporting to a .txt file would great. Because it will probably be printed off anyways for the wire operator. Locations need to from my activated workplane also. thank you

0 Likes

cfastNJWK6
Advisor
Advisor

Should the macro assume there is already an active featureset? Or would you like it to ask what featureset to export locations from?

0 Likes

johnc4668
Advocate
Advocate

@cfastNJWK6 It should probably prompt because sometimes there are multiple setups and featuresets in a project

0 Likes

cfastNJWK6
Advisor
Advisor
Accepted solution

Here is a rather crude version, but it should work for you.  You just have to change the $filename variable to = where you want the file and what to name it.  Exporting as a .csv file makes for easier reading. a txt file not start a new line for each hole.

 

ENTITY $wp = INPUT ENTITY WORKPLANE "Select the workplane to output positions from"
ENTITY $fset = INPUT ENTITY FEATURESET "Select the Featureset to output positions from"
REAL $xPos = 0
REAL $yPos = 0
REAL $zTop = 0
REAL $zBot = 0
STRING $HolePosition = ""
STRING LIST $HoleLocals = {"Xpos, Ypos, ZTop, ZBot"}
STRING $FileName = "C:\temp\HoleLacals.csv"


 FOREACH $feat IN components($fset) {
	EDIT FEATURESET $fset DESELECT ALL
      IF feat.type == 'hole' {
		EDIT FEATURESET $fset SELECT $feat
		EDIT BLOCKTYPE CYLINDER
		EDIT BLOCK LIMITTYPE FEATURESET
		EDIT BLOCK COORDINATE WORKPLANE
		EDIT BLOCK RESET
		$xPos = round($Block.Centre.X, 4)
		$yPos = round($Block.Centre.Y, 4)
		$zTop = round($Block.Limits.ZMax, 4)
		$zBot = round($Block.Limits.ZMin, 4)
		
		$HolePosition = $xpos + ", " + $yPos + ", " + $zTop + ", " + $zBot
		
		int a = add_last($HoleLocals, $HolePosition)
	  
	  }
}  
ECHO OFF DCPDEBUG UNTRACE COMMAND ACCEPT
TRACEFILE OPEN $FileName
FOREACH $line IN $HoleLocals {
		PRINT $line		
	}
TRACEFILE CLOSE
ECHO ON DCPDEBUG TRACE COMMAND ACCEPT

 

johnc4668
Advocate
Advocate

@cfastNJWK6  Wow, this is awesome! This will work great for us. Curious, can you open excel from powermill with a command? I can open a file location i know with:

 

STRING dir = 'C:\temp'
OLE FILEACTION 'open' $dir

 

 

 

 

0 Likes

cfastNJWK6
Advisor
Advisor

If you put this at the end of the macro:

 

OLE FILEACTION 'open' $FileName

 

It will open the file in excel IF excel is your default program for opening csv files.

johnc4668
Advocate
Advocate

@cfastNJWK6  Just curious, i making a different macro at the moment and stole your input drop down command. I sometimes need to copy patterns and dont want to right click through it. How do i activate a pattern after i select it in the drop down box. Heres the current state:

 

DEACTIVATE PATTERN
ENTITY $pattern = INPUT ENTITY PATTERN "Activate then select pattern to copy"
COPY PATTERN ;

0 Likes

cfastNJWK6
Advisor
Advisor

You can actually copy the pattern without activating it like this:

COPY PATTERN $pattern

 

Or if you want to stick with activating and then copying, do this:

ACTIVATE PATTERN $pattern
COPY PATTERN $pattern

 

Using ";" refers to the active entity.  Since you are already declaring a variable ($pattern) you can use that instead.  It can make reading/editing macros a little more clear instead of referencing the active entity all of the time.

johnc4668
Advocate
Advocate

@cfastNJWK6 Perfect, i like the COPY PATTERN $pattern route. This will come in handy, thank you!

0 Likes

PRAMET-DORMERR
Enthusiast
Enthusiast

HOW TO SAVE THIS EXCEL FILE IN PROJECT BY MACRO

0 Likes

malinsAM3TM
Enthusiast
Enthusiast

Dear Sir

I had a similar requirement,

I used this macro to get co ordinates start z and end z 

Sir I need height of the feature set in another colume and diameter in next column

I am attaching excel file and macro which I am using

Waiting for your reply

Thanking You

Nivrutti Mali

Godrej Tooling

Mumbai

 

 

 

0 Likes