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!
Solved! Go to Solution.
Solved by cfastNJWK6. Go to Solution.
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?
@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
Should the macro assume there is already an active featureset? Or would you like it to ask what featureset to export locations from?
@cfastNJWK6 It should probably prompt because sometimes there are multiple setups and featuresets in a project
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
@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
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.
@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 ;
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.
@cfastNJWK6 Perfect, i like the COPY PATTERN $pattern route. This will come in handy, thank you!
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.