LUA Scripting: Issue with getting slice data

LUA Scripting: Issue with getting slice data

quentin_schmidBRKQZ
Enthusiast Enthusiast
530 Views
2 Replies
Message 1 of 3

LUA Scripting: Issue with getting slice data

quentin_schmidBRKQZ
Enthusiast
Enthusiast

Hi,

 

I am trying to get the area of a given slice. I tried this :

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

local LayerThickness = 1.0;
local layerRecoatTime = 10.0;
local contourLaserScanSpeed = 900.0;
local hatchLaserScanSpeed = 1100.0;
local hatchDistance = 0.1;
local hl = 2.0;
 
system:setloggingtooglwindow(true);
 
local Nl = slicetray.layercount;
 
 
for i=0, Nl-1 do
Si = slice.calculateslicearea(sliceindex:i);
end;
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
As it is indicated in the documentation, but it yields the error 
'''''''''''''''''''''''''''''''
2025-02-27 16:37:27;LUA Syntax Error: [string "ComputeBuildTimeEstimate.lua"]:14: function arguments expected near ')';General
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
 
thanks
 
 
0 Likes
Accepted solutions (1)
531 Views
2 Replies
Replies (2)
Message 2 of 3

steffen_anders_adsk
Autodesk Support
Autodesk Support
Accepted solution

Hello,

 

That's a typo.

slice.calculateslicearea, with a period, tries to access the method as if it was a property, but it's not and as such needs a colon: slice:calculateslicearea()

Plus, sliceindex:Int in the documentation means that the single parameter the method expects is an integer. (Not because Lua requires it but because you can't have fractional layers.) The method's parameter doesn't actually have a name; that's just there for the reader to tell for what the method wants that parameter. So, for your example, you'll want slice:calculateslicearea(i).

 

Best regards,

Steffen

Steffen Anders
Autodesk Netfabb team

Netfabb resources: Online help • System requirements • Knowledge base • Forums • Homepage • YouTube

How to get Netfabb Basic: Video • Help • Download

0 Likes
Message 3 of 3

quentin_schmidBRKQZ
Enthusiast
Enthusiast

Hi Steffen. It worked many thanks for your support