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: 

How can i get hole feature set xyz locations?

12 REPLIES 12
SOLVED
Reply
Message 1 of 13
johnc4668
1138 Views, 12 Replies

How can i get hole feature set xyz locations?

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!

12 REPLIES 12
Message 2 of 13
cfastNJWK6
in reply to: johnc4668

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?

Message 3 of 13
johnc4668
in reply to: cfastNJWK6

@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

Message 4 of 13
cfastNJWK6
in reply to: johnc4668

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

Message 5 of 13
johnc4668
in reply to: cfastNJWK6

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

Message 6 of 13
cfastNJWK6
in reply to: johnc4668

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

 

Message 7 of 13
johnc4668
in reply to: cfastNJWK6

@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

 

 

 

 

Message 8 of 13
cfastNJWK6
in reply to: johnc4668

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.

Message 9 of 13
johnc4668
in reply to: johnc4668

@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 ;

Message 10 of 13
cfastNJWK6
in reply to: johnc4668

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.

Message 11 of 13
johnc4668
in reply to: cfastNJWK6

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

Message 12 of 13
PRAMET-DORMERR
in reply to: cfastNJWK6

HOW TO SAVE THIS EXCEL FILE IN PROJECT BY MACRO

Message 13 of 13
malinsAM3TM
in reply to: cfastNJWK6

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

 

 

 

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

Post to forums  

Autodesk Design & Make Report