Notes and Stock size added to post header.

Notes and Stock size added to post header.

Anonymous
Not applicable
1,345 Views
9 Replies
Message 1 of 10

Notes and Stock size added to post header.

Anonymous
Not applicable

I have added setup notes to my post, but it is posting as one long run on sentence.. 

Is there a way to add line breaks/ carriage returns so that it is not one long line in the post code?

 

  var notes = getGlobalParameter("job-notes");
  writeComment("SETUP NOTES - "+ notes);

 

When I type notes like 

.250 MIN STICKOUT ABOVE VICE JAWS

X ZERO LEFT OF STOCK

Y ZERO FIXED JAW

Z ZERO TOP OF STOCK

 

It posts out as 

.250 MIN STICKOUT ABOVE VICE JAWSX ZERO LEFT OF STOCKY ZERO FIXED JAWZ ZERO TOP OF STOCK

 

 

 

 

Also, I decided adding stock size would be beneficial to our operators as well. I was able to get the stock size to post by adding the following,

// Add Stock size to top of program
var stockSize = getGlobalParameter("stock");
writeComment("STOCK SIZE - "+ stockSize);

 

Which in this case results with,

; STOCK SIZE - 0, -120.65, -9.525, 152.4, 0, 0


Can you help me in converting this to display as Inch / Imperial rather than metric?  Also, if we could do away with the minus symbols and the 3 zeros which are not needed that would be great.

 

What happens is these programs get saved to our server and sometimes left on the CNC controls and the job might come back a year or two later and if we had material in stock that was not the same exact size as last time it can cause tools to rapid plunge into stock that maybe did not exist last time the job was run.  I just feel as though the more information I can have in the program itself, the more the operator can double check before running the parts.

0 Likes
Accepted solutions (2)
1,346 Views
9 Replies
Replies (9)
Message 2 of 10

Anonymous
Not applicable

Post example 

 

: (PGM, NAME="CC1046.1114OP4")
; DATE THURSDAY, NOVEMBER 14, 2019 085447
; T2 D=0.5 CR=0 - ZMIN=0.75 - FLAT END MILL
; SETUP NOTES - HANG THE T FEATURE OUT OF THE LEFT SIDE OF THE VICE. LEAVE AT LEAST 38 GAP BETWEENTHE JAW AND THE EAR HANGING OUT FOR TOOL CLEARANCE. LEAVE AT LEAST .600 ABOVE JAWFOR TOOL CLEARANCE. X ZERO LEFT SIDE OF FINISH PARTY ZERO BACK FIXED JAWZ ZERO TOP OF JAW
; STOCK SIZE - 2.84217E-14, -43.7896, -14.605, 165.1, 0, 33.655
: G90 G40 G94

 

I would like this to read out as the following

 

: (PGM, NAME="CC1046.1114OP4")
; DATE THURSDAY, NOVEMBER 14, 2019 085447
; T2 D=0.5 CR=0 - ZMIN=0.75 - FLAT END MILL
; SETUP NOTES - HANG THE T FEATURE OUT OF THE LEFT SIDE OF THE VICE.

; LEAVE AT LEAST .375 GAP BETWEEN THE JAW AND THE EAR HANGING OUT FOR TOOL CLEARANCE.

; LEAVE AT LEAST .600 ABOVE JAWFOR TOOL CLEARANCE.

; X ZERO LEFT SIDE OF FINISH PART

; Y ZERO BACK FIXED JAW

; Z ZERO TOP OF JAW
; STOCK SIZE - X6.5, Y1.724, Z1.9
: G90 G40 G94

0 Likes
Message 3 of 10

asljg
Participant
Participant

You can customize good POST here!

0 Likes
Message 4 of 10

FTKnur
Collaborator
Collaborator
Accepted solution

Hi @Anonymous ,

 

try this:

  if (hasGlobalParameter("job-notes")) {
	var notes = getGlobalParameter("job-notes");
		if (notes) {
			writeBlock("M0")
	var lines = String(notes).split("\n");
	var r1 = new RegExp("^[\\s]+", "g");
	var r2 = new RegExp("[\\s]+$", "g");
	for (line in lines) {
	var comment = lines[line].replace(r1, "").replace(r2, "");
		if (comment) {
			writeComment(comment);
				}
			}
		}
	}
Message 5 of 10

boopathi.sivakumar
Autodesk
Autodesk
Accepted solution

In addition to it you can add this codes to post out the stock size

  var xlow = getGlobalParameter("stock-lower-x")/25.4;
  var xupp = getGlobalParameter("stock-upper-x")/25.4;
  var ylow = getGlobalParameter("stock-lower-y")/25.4;
  var yupp = getGlobalParameter("stock-upper-y")/25.4;
  var zlow = getGlobalParameter("stock-lower-z")/25.4;
  var zupp = getGlobalParameter("stock-upper-z")/25.4; 
writeComment("STOCK SIZE - "+xOutput.format(xupp-xlow)+" , "+yOutput.format(yupp-ylow)+" , "+zOutput.format(zupp-zlow));

Boopathi Sivakumar
Senior Technology Consultant

Message 6 of 10

Anonymous
Not applicable

Here is code for stock size (I don't remember who to credit):

 

    var workpiece = getWorkpiece();
    var delta = Vector.diff(workpiece.upper, workpiece.lower);

(For milling post:) 
    writeComment(" Stock dimension Z = " + stocksizeFormat.format(delta.z) + " ");
    writeComment(" Stock dimension X = " + stocksizeFormat.format(delta.x) + " ");
    writeComment(" Stock dimension Y = " + stocksizeFormat.format(delta.y) + " ");

(For turning post:)

    writeComment(" Stock length = " + stocksizeFormat.format(delta.z) + " ");
    writeComment(" Stock diameter = " + stocksizeFormat.format(delta.x) + " ");

 

 

Thank you for the code for outputing setup instructions entered by the user through the Edit Notes function!

 

0 Likes
Message 7 of 10

reeltime273
Participant
Participant

Hello All,

 

I also have wanted to add set up notes to my post,  it will make it easier for me while at my machine.   I have tried to add this information but have been unsuccessful, however and have been able to include post time a a few generic notes, this is all that I can get to work.  I have tried to copy and paste into my post what others have suggested, however,  the post will not load into Fusion or it fails to to post on the Visual Studio Code (VSC).   In the notes I would like to include stock size, material, info on where to zero part and anything else that others can suggest.   I have included a good working post.  For my machine, I utilize a generic Mach3 Mill post that I downloaded from fusion 360, which I also have included.  Please let me know if I need to provide any additional info.   

 

Thanks in advance for some guidance!

Mark, 

0 Likes
Message 8 of 10

Engineering2PJ4TC
Community Visitor
Community Visitor

Where do you copy and paste the code?

0 Likes
Message 9 of 10

Engineering2PJ4TC
Community Visitor
Community Visitor

Where do you paste this code to get it to actually work?   I have not been successful

 

0 Likes
Message 10 of 10

andrew.millardCYPQ9
Autodesk
Autodesk

You can add this directly to where the other comment lines have been added in onOpen()
andrewmillardCYPQ9_0-1750854024183.png

The reason that this was failing is because you are trying to format delta.z, delta.x and delta.y with a format that hasn't been created.
If you create a new format called stocksizeFormat with the rest of the formats above, you will then get code outputting. 
You can manipulate the format however you need the code to look - 
andrewmillardCYPQ9_1-1750854166021.png

andrewmillardCYPQ9_3-1750854293232.png

 

 

If my post answers your question, please click the 'Accept Solution' button. This helps everyone find answers more quickly!



Andy Millard

Product Support Specialist


0 Likes