jeff.D

Verified Members
  • Content count

    199
  • Joined

  • Last visited

Community Reputation

97 Excellent

1 Follower

About jeff.D

  • Rank
    Member

Recent Profile Visitors

845 profile views
  1. jeff.D

    Buffer help, I think?

    I learned how to do the above from the MP docs. I know some classes are offered online; I've never taken one, so I can't speak to what they teach.
  2. jeff.D

    Buffer help, I think?

    No, you shouldn't do any of that. All you need to do is call pwrite_tool_info, that will take care of everything. With this method you do not need to capture the tool information as the operation is being processed; pwrite_tool_info will gather the information at any time.
  3. jeff.D

    Buffer help, I think?

    A stack is a buffer with different options. Stacks also have performance advantages under certain conditions. You can call pwrite_tool_info from anywhere in the post EXCEPT the parameter read post blocks. This is because we are doing our own sequential read of the operations with the streaminfo function. As you've noticed, the stack uniquifies the tools so none are repeated.
  4. jeff.D

    Buffer help, I think?

    You're likely doing more work than you have to. If you are in Mastercam 2017 or later you could do something like this... [POST_VERSION] #DO NOT MOVE OR ALTER THIS LINE# V22.00 P0 E1 W22.00 T1550094727 M22.00 I0 O1 return : 0 #Default english/metric position format statements fs2 1 0.7 0.6 #Decimal, absolute, 7 place, default for initialize (:) fs2 2 0.4 0.3 #Decimal, absolute, 4/3 place fs2 3 0.4 0.3d #Decimal, delta, 4/3 place #Common format statements fs2 4 1 0 1 0 #Integer, not leading op_identity : 0 tool_number : 0 tool_offset : 0 tool_length_offset : 0 tool_diameter : 0 tool_corner_radius : 0 pget_tool_parameters(op_identity) tool_number = opinfo(47, op_identity, 1) tool_offset = opinfo(49, op_identity, 1) tool_length_offset = opinfo(50, op_identity, 1) tool_diameter = opinfo(10005, op_identity, 1) tool_corner_radius = opinfo(10006, op_identity, 1) stack_tool_number : 0 stack_tool_offset : 0 stack_tool_length_offset : 0 stack_tool_tool_diameter : 0 stack_tool_corner_radius : 0 stack_size : 0 stack_result : 0 fstack 1 5 is_tool_in_stack : no$ padd_tool_to_stack is_tool_in_stack = no$ stack_size = pop(1, stack_result, 0) while stack_size > 0, [ stack_tool_number = pop(1, stack_size, 5) if stack_tool_number = tool_number, [ is_tool_in_stack = yes$ stack_size = -1 ] stack_size = stack_size - 1 ] if not(is_tool_in_stack), [ tool_number = push(1, stack_result, 0) ] stream_idx : 1 stream_op_id : 0 output_tool_number : 0 output_tool_offset : 0 output_tool_length_offset : 0 output_tool_diameter : 0 output_tool_corner_radius : 0 fmt "Number -> " 2 output_tool_number fmt "Diameter Offset-> " 2 output_tool_offset fmt "Length Offset -> " 2 output_tool_length_offset fmt "Diameter -> " 2 output_tool_diameter fmt "Corner Radius -> " 2 output_tool_corner_radius pwrite_tool_info stream_idx = 1 stream_op_id = streaminfo(1, stream_idx) while stream_op_id <> -99999, [ pget_tool_parameters(stream_op_id) padd_tool_to_stack stream_idx = stream_idx + 1 stream_op_id = streaminfo(1, stream_idx) ] stack_size = pop(1, stack_result, 0) while stack_size > 0, [ output_tool_number = pop(1, stack_size, 5) "(Tool Information)", e$ "( ", *output_tool_number, ")", e$ "( ", *output_tool_offset, ")", e$ "( ", *output_tool_length_offset, ")", e$ "( ", *output_tool_diameter, ")", e$ "( ", *output_tool_corner_radius, ")", e$ *e$ stack_size = stack_size - 1 ] pheader$ "(--- Header---)", e$ pwrite_tool_info *e$ peof$ "(--- End-of-File---)", e$ pwrite_tool_info *e$ Sample Output (--- Header---) (Tool Information) ( Number -> 1. ) ( Diameter Offset-> 1. ) ( Length Offset -> 1. ) ( Diameter -> .5 ) ( Corner Radius -> 0. ) (Tool Information) ( Number -> 287. ) ( Diameter Offset-> 287. ) ( Length Offset -> 287. ) ( Diameter -> .375 ) ( Corner Radius -> 0. ) (--- End-of-File---) (Tool Information) ( Number -> 1. ) ( Diameter Offset-> 1. ) ( Length Offset -> 1. ) ( Diameter -> .5 ) ( Corner Radius -> 0. ) (Tool Information) ( Number -> 287. ) ( Diameter Offset-> 287. ) ( Length Offset -> 287. ) ( Diameter -> .375 ) ( Corner Radius -> 0. )
  5. You can also set up a multi-check as shown below. is_drilling_op = ( tool_op$ = 2 | tool_op$ = 475 | tool_op$ = 37 | tool_op$ = 104 | tool_op$ = 136 | tool_op$ = 306 ) is_drilling_op will be set to yes$(1) if a condition in the rounded brackets is true. For this to work, newglobal$ must be set to 1.
  6. I'm not an MP expert but I know a little bit and I'll do my best to help. Have you initialized the following variables in your post? stool_name : "" squery_invalid := "-99999" sempty_string := "" In order to initialize a variable, it must be placed up against the left margin of the file, as shown above.
  7. You have uninitialized variables on lines 621, 701, and 784. The number in brackets is the column position of the start of the uninitialized variable, so that should help you track it down. Once you have that sorted, I would try calling ptool_name where you were calling pstrtool.
  8. What version of Mastercam are you using? It's likely the regex thats holding you up. Try the modified version below. stool_name : "" squery_invalid := "-99999" sempty_string := "" ptool_name #Comment for tool stool_name = opinfo(10094, 0) if stool_name <> sempty_string | stool_name <> squery_invalid, [ stool_name = ucase(stool_name) *stool_name ]
  9. jeff.D

    Roundup Function?

    I found an error in the code snippet I posted previously, a corrected version is below. [email protected] : 1 [email protected] : 2 [email protected] : -99999 value : 0 type : [email protected] int_value : 0 frac_value : 0 #//The first argument is being passed by reference '!' #//'type' is initialized to [email protected](1) and set to [email protected](1) at the end of 'pround' #//Because of this, we can consider 'type' optional pround(!value, type) #//Get the integer portion of the passed in value int_value = int(value) #//Get the fractional portion of the passed in value #//The fractional portion is not used in this example frac_value = frac(value) if type = [email protected], [ value = int_value + 1 ] else, if type = [email protected], [ value = abs_value ] else, [ value = [email protected] ] type = [email protected] #//Calling example #//Output (depending on format) -> #// x_abs is : 4.75342 #// x_abs rounded up is : 5 #// x_abs rounded down is: 4 #// #// x_abs rounded up is : 5 x_abs : 0 y_abs : 0 z_abs : 0 pany_postblock x$ = 4.75342 x_abs = vequ(x$) "x_abs is :", *x_abs, e$ pround(!x_abs, [email protected]) "x_abs rounded up is :", *x_abs, e$ x_abs = vequ(x$) pround(!x_abs, [email protected]) "x_abs rounded down is:", *x_abs, e$ *e$ #//The 'type' argument is optional x_abs = vequ(x$) pround(!x_abs) "x_abs rounded up is :", *x_abs, e$ It's also worth noting that this example will only work for positive numbers. It would need to be modified to round positive and negative numbers correctly.
  10. Thanks, but you didn't have to bother; I got the jist of it from you're first project.
  11. jeff.D

    Roundup Function?

    MP has a round( ) function, but I don't see any way to ensure you're always rounding up. There is also the rounding method in the format statement, but based on the definition below I don't think it will help you Rounding method. Use the following values: (omitted) - Normal rounding. 2 - Round final decimal to nearest even number. 5 - Round final decimal to nearest multiple of 5. 9 - Truncate the decimal portion of the value at the specified number of digits. Below is an example that should round the passed in value up (or down), but I can't test it. Maybe it will help you. [email protected] : 1 [email protected] : 2 [email protected] : -99999 value : 0 type : [email protected] int_value : 0 frac_value : 0 #//The first argument is being passed by reference '!' #//'type' is initialized to [email protected](1) and set to [email protected](1) at the end of 'pround' #//Because of this, we can consider 'type' optional pround(!value, type) #//Get the integer portion of the passed in value int_value = int(value) #//Get the fractional portion of the passed in value #//The fractional portion is not used in this example frac_value = frac(value) if type = [email protected], [ value = int_value + 1 ] if type = [email protected], [ value = abs_value ] else, [ value = [email protected] ] type = [email protected] #//Calling example #//Output (depending on format) -> #// x_abs is : 4.75342 #// x_abs rounded up is : 5 #// x_abs rounded down is: 4 #// #// x_abs rounded up is : 5 x_abs : 0 y_abs : 0 z_abs : 0 pany_postblock x$ = 4.75342 x_abs = vequ(x$) "x_abs is :", *x_abs, e$ pround(!x_abs, [email protected]) "x_abs rounded up is :", *x_abs, e$ x_abs = vequ(x$) pround(!x_abs, [email protected]) "x_abs rounded down is:", *x_abs, e$ *e$ #//The 'type' argument is optional x_abs = vequ(x$) pround(!x_abs) "x_abs rounded up is :", *x_abs, e$
  12. I downloaded the repo, thanks for the example. This is likely the same approach I intended on taking. Native code compiled to a static library, then a CLR wrapper dll for use with .NET.
  13. I want to use unmanaged code in a NET-Hook. I'm interested in what you've done; do you have a GitHub?
  14. sdq : '"' fmt "Inches: " 4 inches sdq #// Output -> Inches: 12" (Depending on format) pany_postblock inches = 12 *inches, e$ or sstring : "" #// Output -> Inches-> " pany_postblock sstring = "Inches-> " + '"' sstring, e$

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us