Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

Zaffin_D

Verified Members
  • Posts

    374
  • Joined

  • Days Won

    1

Everything posted by Zaffin_D

  1. I think this is a good idea, but the code leaves a bit to be desired. In an effort to help you out I created a more organized example. It's not 100% yet, but you can read in an .NC file and obtain a tool list and the min and max X,Y,Z values. I hope it helps.
  2. Yes.* NET-Hook's are not version dependent like C-Hooks. *NETHOOK_3.dll changes between Mastercam versions, so sometimes functions are deprecated or updated.
  3. Download it from Mastercam's tech exchange; that way you can review the entire post.
  4. Hi Brad, If you're using the enhanced tool table that was introduced in Mastercam 2017 check out the Techno Titan post on the Mastercam tech exchange. The Titan post has a postblock to output the tools minium Z.
  5. That's not surprising, strictly speaking the answer to your question is no; MP.dll can not make changes to the Mastercam file.* However, if a Mastercam Add-in is created, the post can call that and it can be used to do all sorts of things to the Mastercam file. Just so you're aware, the help your looking for likely will not be free. *Prior to Mastercam X8, MP.dll could draw basic geometry in the Mastercam file, but the functions have since been deprecated.
  6. Not exactly. The post can access the tools slot ID, so we can look up and modify the tool using a NET-Hook and ToolNetApi.dll. However, this would not effect the NCI file that's currently being processed, only the source files tool system. What you're asking for is possible, have you contacted your reseller or CNC's post department for help? That would be my first stop.
  7. I'm allergic to VB.Net's syntax; below is a (very) basic c# example. namespace ToolNetApiExample { using Mastercam.App; using Mastercam.App.Types; using Cnc.Tool.Interop; public class Main : NetHook3App { public override MCamReturn Run(int param) { var toolSystem = TlToolFunctions.GetToolSystem(); var endMill = new TlToolEndmill() { Name = "Example .5in Reduced Shank Tool", OverallDiameter = .5, TruePhysicalLength = 4, CuttingDepth = .375, ShoulderLength = 2.0, ShoulderDiameter = .375, ArborDiameter = .5, IsMetric = false }; var toolAssembly = new TlAssembly() { MainTool = endMill, }; toolSystem.Add(toolAssembly); return MCamReturn.NoErrors; } } }
  8. Have you looked at the ToolNetApi.dll that ships with the newer versions of Mastercam?
  9. What version of Mastercam are you using?
  10. I'm posting just to remind myself to put the NET-Hook I use to trace geometry up on GitHub. It's just a modal dialogue that lists the levels used in the selected operation. Nothing fancy, but it handles most operation types.
  11. You're likely not linking the library when building. You need to tell the linker to link the library that contains the create_point_ent function you're trying to use.
  12. That's odd, the below snippet works for me no matter what the Mastercam plane's are set to. I always get a contour op with the WCS/T Plane/C Plane set to Top. bool AddContourOp(double clearancePlane, double feedPlane, double topOfStock, double depth) { bool result = false; CInterrogateMastercamFile fileInterrogator; fileInterrogator.Load(); MastercamPlanes * mcPlanes = static_cast<MastercamPlanes *>(fileInterrogator.GetpPlanes()); Plane topPlane = mcPlanes->GetTopPlanePtr(); op_view topView; topPlane.Convert(topView, *mcPlanes); operation op = {}; DB_LIST_ENT_PTR dbPtr; operation_manager(&op, OPMGR_INIT, &dbPtr, &result); op.opcode = TP_CONTOUR; op.WCS = topView; op.tpln = topView; op.cpln = topView; op.cmn.clearance_pln = clearancePlane; op.cmn.feed_pln = feedPlane; op.cmn.top_stock = topOfStock; op.cmn.depth = depth; operation_manager(&op, OPMGR_ADD, &dbPtr, &result); return result; }
  13. I think I understand what you're asking. Are you aware that a .ft file can point to multiple functions? ############################################################################## # Public functions here ############################################################################## # # The main system entry point FUNCTION NET "Run" dnSPNG "Run16" dnLPNG "Run24" dnTIP "RunTip" END_FUNCTION FUNCTION NET "Custom" dnTIP "CustomTip" dnSPNG "CustomSmall" dnLPNG "CustomLarge" END_FUNCTION If I'm off the mark let me know.
  14. I'm not a developer or a cpp guy, but give the below snippet a shot. Hopefully a real cpp developer chimes in... bool SetToolPlaneToTop(int opID, bool regen = false) { ent operationEntity; if (TpMainOpMgr.GetMainOpList().DatabaseRetrieve(opID, operationEntity)) { CInterrogateMastercamFile fileInterrogator; fileInterrogator.Load(); MastercamPlanes * planes = static_cast<MastercamPlanes *>(fileInterrogator.GetpPlanes()); Plane top = planes->GetTopPlanePtr(); op_view topView; top.Convert(topView, *planes); operationEntity.u.op.tpln = topView; TpMainOpMgr.GetMainOpList().UpdateListAndDB(operationEntity, false); if (regen) { DB_LIST_ENT_PTR dbPtr; bool result = false; operation_manager(&operationEntity.u.op, OPMGR_NCI_REGEN, &dbPtr, &result); } return true; } else { return false; } }
  15. 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.
  16. 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.
  17. 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.
  18. 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. )
  19. 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.
  20. 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.
  21. 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.
  22. 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 ]
  23. I found an error in the code snippet I posted previously, a corrected version is below. UP@ : 1 DOWN@ : 2 ERROR@ : -99999 value : 0 type : UP@ int_value : 0 frac_value : 0 #//The first argument is being passed by reference '!' #//'type' is initialized to UP@(1) and set to UP@(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 = UP@, [ value = int_value + 1 ] else, if type = DOWN@, [ value = abs_value ] else, [ value = ERROR@ ] type = UP@ #//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, UP@) "x_abs rounded up is :", *x_abs, e$ x_abs = vequ(x$) pround(!x_abs, DOWN@) "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.

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

×
×
  • Create New...