Getting Started with Lua

This section is for general discussion about Gadgets
Post Reply
unicacher
Posts: 7
Joined: Tue Dec 26, 2017 2:03 am
Model of CNC Machine: ShopBot Desktop

Getting Started with Lua

Post by unicacher »

Once upon a time, I was a fairly proficient code writer--- like 20 years ago. Between time and changes in syntax and structure, the gears are getting stuck.

Could I get a nudge forward? Given this code as a base, how do I return the number of objects on the selected layer? Currently, I get "no static 'CadLayer' in class 'CadLayerManager'". I've tried several combinations of this property structure with the same results.

Code: Select all

-- VECTRIC LUA SCRIPT

function main()
	job = VectricJob()
	layer = job.LayerManager:GetActiveLayer()

	objects = CadLayerManager.CadLayer.Count
	
	MessageBox ("objects=" .. objects)

	return true
end
I think once I see the correct structure of the properties, it'll make sense.

User avatar
Adrian
Vectric Archimage
Posts: 14503
Joined: Thu Nov 23, 2006 2:19 pm
Model of CNC Machine: ShopBot PRS Alpha 96x48
Location: Surrey, UK

Re: Getting Started with Lua

Post by Adrian »

Have a look at the Layer_Example script in the SDK. That has a function that counts objects on a layer.

Post Reply