Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

NaN error in posted GCode, not VSCode

LorroPrecision
Contributor

NaN error in posted GCode, not VSCode

LorroPrecision
Contributor
Contributor

Hi

 

I'm working on a custom post to do some turning for my Hurco mill. I'm getting some NaN errors in the posted GCode when I use my post my setup from fusion. If I create a .cnc file from the same setup and use VSCode to edit the post, the GCode that VSCode produces does not have these errors.

 

Sometimes I have found that creating a new cutting strategy with exactly the same parameters will not produce these errors, and other times it does.

 

GCode posted straight from Fusion

LorroPrecision_0-1712758267110.png

 

Exact same setup produced in VSCode with the same, unedited post and .cnc file

LorroPrecision_1-1712758389146.png

 

Does anyone have any tips on how I might be able to debug this?

 

Thanks

0 Likes
Reply
Accepted solutions (1)
387 Views
5 Replies
Replies (5)

viacheslav.shapilov
Autodesk
Autodesk

Hello, @LorroPrecision , could you share your project and post for investigation? You can do it through private message.
But in general, people just print out some intermediate values into output for debugging. We don't have an interactive debugger.


Viacheslav Shapilov
Developer Technical Services
Autodesk Developer Network


0 Likes

LorroPrecision
Contributor
Contributor

Hi Viacheslav

 

It's not a NDA project so it should be fine.

 

The post is probably not the easiest to decipher as I'm a bit bodgy when it comes to coding.

 

Thanks

0 Likes

viacheslav.shapilov
Autodesk
Autodesk
Accepted solution

Looked a bit into the issue. Seems it is in updating tool offsets. You are setting them on tool object directly. And not always. So, they can be undefined in some situations. And as this object is managed by postprocessor, it gets recreated for each operation effectively loosing all properties you set on it in the post. If you want to set properties in tool object directly, you have to do this on each section. But I'd advise to store them separately in some other place. Just to be sure, it is fully under you control. Alternatively, if you are familiar with classes, you can create on-the fly calculated properties inside Tool class. But it is more complicated to do.

 

Not sure why you cannot reproduce it in the VS Code. I see the same output both in Fusion and in VS Code. Probably, on your side VS Code uses some old postprocessor (from one of previous Fusion releases). We had an issue, when JS object wrappers were not recreated on each section leading to some other problems in existing posts. But it is fixed now.

 


Viacheslav Shapilov
Developer Technical Services
Autodesk Developer Network


0 Likes

LorroPrecision
Contributor
Contributor

Thanks a lot.

 

Yeah I was setting the offsets from within 

if(insertToolCall)

which doesn't get seen on the 2nd operation with the same tool. Strange that VSCode wasn't throwing the error. In VSCode it says the Autodesk extension was updated 14th March, not sure if there has been an update since then.

 

The hacky way you noted of moving it outside that conditional has done the job.

 

When you say store them somewhere else, is there a way to store variables like a global variable where it is accessible across the length of processing the file?

 

Thanks

0 Likes

viacheslav.shapilov
Autodesk
Autodesk

Yes, you can define some variable in global scope (outside of any function) to hold extra data, like:

var toolEx = {
  offsetx = 0,
  offsety = 0,
  ...
};

And use it instead of tool inside functions.

BTW, you can change post in VS Code extension by F1 command:

viacheslavshapilov_0-1712911050105.png

And point it into latest Fusion, that is somewhere in: %LocalAppData%\Autodesk\webdeploy\release\<some id>\Applications\CAM360\post.exe . But I thought, it does it automatically.



Viacheslav Shapilov
Developer Technical Services
Autodesk Developer Network