June 6, 2018

Deep Joy


First, I’d like to acknowledge Mr. or “Professor” Stanley Unwin as the inspiration for the thought of a title for this brief technical item.

Stanley Unwin was a remarkable British ( but South African-born ) comedian who had a long showbusiness career ( yet to call him a comedian seriously undermines his talent ).

If you’ve not experienced his unique work then do look up the video clips that are out there on the ‘net. I think you’ll be impressed and enthralled J

So, why ‘Deep Joy’?
Part of my week has been spent working on macro code for a particular SmartCAM requirement. Allow me to provide some background.

I’m an engineer, a sort of a Production / Mechanical hybrid, really. I once overheard a remark by a software professional, a proper computer scientist, as it were, of an engineer who had successfully followed a career in software development and business management. And highly talented he was, too ( both of them were, in fact, the engineer and the developer ).

The developer claimed that the engineer ‘wrote code like an engineer’. I kind of knew immediately what he might have meant by that.

Throughout my CAM career I have had the good fortune – because it is a part of this job that I like doing - to have the need and to be capable of creating bits and pieces of software for this-or-that purpose or repetitive task using various programming languages.

I consider myself to be a capable software writer. For an engineer, that is.

I always try my best to create structured, elegant code. Neat, compact and efficient code is almost a work of art and is to be admired. Or at least it is that to me, anyhow. But that’s another topic for another day. My professional development colleagues could, I’m sure, provide much interesting comment and input on how to structure program source code.

I’m not asking for that, nor am I asking for anybody to comment on my code style. I daren’t J

My Deep Joy, lightbulb moment
hit me when I wanted to include macro code to check for an arc that ran from left to right and was in a counter clockwise direction or ran from right to left and was in a clockwise direction.


Quite a simple requirement, then. Initially, I wrote code that checked each of those conditions separately but then thought I could do it in one. I have to admit that our documentation didn’t really help confirm that I could do so, but my code worked.

It is comprised of nested logical operators. My little piece of code ended up as:

IF ( TYP ( #rev_grpe ) = 3 ) //is the current element an arc
IF (
//is this arc from right to left and is clockwise?
( ENX ( #rev_grpe ) < STX ( #rev_grpe ) ,AND DIR ( #rev_grpe = 0 ) )
,OR
//is this arc from left to right and is counter-clockwise?
                        ( STX ( #rev_grpe ) < ENX ( #rev_grpe ) ,AND DIR ( #rev_grpe = 1 ) )
)
           
             // one of those sets of conditions is true
                       // do whatever it is you need to do here   
                         
            ENDIF
ENDIF

I’ve stuck with those OR and AND operators out of habit, but the modern || and && equivalents can equally well be used.

I know, I know – it doesn’t look much in print here, and that stuff perhaps won’t be a revelation to many but I believe that that small technical detail will generally be of interest to users of the SmartCAM Customization ToolKit, or CTK, using which this code has been created.

It appealed to me, anyway, and that is the main thing as far as I am concerned.

The SmartCAM CTK
This isn’t a lesson in the CTK. And you’d need to purchase SmartCAM in order to understand and benefit from that particular functionality of our CAM system. The CTK is enabled at no charge on every user licence we supply.

I should add that creating customization isn’t a case of having to write that macro code line-by-line. The CTK includes functionality whereby macro code can be created by recording commands during interaction within the application.

I always am of the opinion that the results that can be achieved using the SmartCAM CTK is only really limited by the imagination. The ToolKit includes a wealth of functions and programming commands and is, of course, fully integrated into the SmartCAM environment. If you should hit an apparent ‘brick wall’ when creating customization then there is usually a method of working around it.

I realise here that this blog post could do with some pictures. Here are a couple of screen shots of a hydraulic / pneumatic seal turning programming application created using the CTK. As well as the logic / code, control panels can be created and incorporated into the SmartCAM user interface.

A User Interface Panel created using the SmartCAM CTK



Seal Geometry
Created by the customization


Seal Manufacturing Toolpaths
Created by the customization




















With such customization, it is perfectly possible to achieve 100% accurate and safe code completely automatically. In this case the macro code includes a number of checks on the inputs in order to ensure as much as possible that the input data is not 'rubbish', is not going to produce errors.

I know from experience that users of this kind of parametric part automation seldom bother to graphically check the toolpath or code, they just go straight ahead and cut the thing.

The SmartCAM CTK ( and also for that matter our code generation ) tools are amongst the most open in the industry – many of our customers use them to create small or not-so-small functionality that is perhaps unique to their own needs and practices – and many of our reseller sales partners sell a customization consultancy and creation service.

I’ll maybe elaborate further on the scope of the SmartCAM CTK in a future post right here in the SmartCAMcnc Blog.

I’m glad to have shared my Deep Joy moment with you. Thank you for your attention. Thank you, Stanley, and thank goodness for the SmartCAM CTK J 

Bye for now. Take care. Have a great day / evening / weekend.

Talk CAM with us. We're at:
+1 (541) 344-4563




No comments:

Post a Comment