How do you Group Objects on a Layer

How do you Group Objects on a Layer

Hi All,

I am looking to Group objects on a layer.

here is my code:

-- VECTRIC LUA SCRIPT
require "strict"
--Global variables
-- ==============================================================================
function Polar2D(pt, ang, dis)
local y_ = dis * math.sin(math.rad(ang))
local x_ = dis * math.cos(math.rad(ang))
return Point2D((pt.X + x_), (pt.Y + y_))
end -- function end
-- ==============================================================================
--function main(script_path)
function main()
local lay = "A"
local job = VectricJob()
if not job.Exists then
return false;
end
local pt1 = Point2D(3.0,3.0)
local pt2 = Polar2D(pt1, 0, 12)
local pt3 = Polar2D(pt2, 90, 22)
local pt4 = Polar2D(pt3, 180, 12)
local pt5 = Polar2D(pt1, 45, 7)
local pt6 = Polar2D(pt5, 90, 1)
local pt7 = Polar2D(pt5, 180, 1)
local layer = job.LayerManager:GetLayerWithName(lay)
local line = Contour(0.0)
line:AppendPoint(pt1)
line:LineTo(pt2) ; line:LineTo(pt3)
line:LineTo(pt4) ; line:LineTo(pt1)

line = Contour(0.0)
line:AppendPoint(pt6)
line:ArcTo(pt7, 1.0)
line:ArcTo(pt6, 1.0)

-- Group all on Layer "A"

job:Refresh2DView()
return true
end
Thanks,
Jim

jimandi5000

Posts: 30
Joined: Wed Mar 11, 2015 6:50 pm
Location: North Houston Tx.
Model of CNC Machine: Home Made 60 x 120

Re: How do you Group Objects on a Layer

Iterate through the layer and add to the group.

Vectric Archimage

Posts: 9596
Joined: Thu Nov 23, 2006 2:19 pm
Location: Surrey, UK
Model of CNC Machine: ShopBot PRS Alpha 96x48

Re: How do you Group Objects on a Layer

That is what I don't know how to do.
Thanks,
Jim

jimandi5000

Posts: 30
Joined: Wed Mar 11, 2015 6:50 pm
Location: North Houston Tx.
Model of CNC Machine: Home Made 60 x 120

Re: How do you Group Objects on a Layer

Have you got the SDK? All the info you need is in the PDF and example scripts.

Vectric Archimage

Posts: 9596
Joined: Thu Nov 23, 2006 2:19 pm
Location: Surrey, UK
Model of CNC Machine: ShopBot PRS Alpha 96x48

Re: How do you Group Objects on a Layer

I have been looking at it... I do not see the CAD Object Model hierarchy in the PDF. Not knowing the structure, I am just doing it by trail and error. I have produced a lot of AutoCAD (Lsp, Visual Lsp & C++) programs and AutoDesk provides a CAD Object Model in their SDK.

This is what I am thinking:
From the most Top level to Bottom

1. Job - You can only have one if the Job has been setup. Not sure what is above this.
2. Layer - 0 - 256 (not 100% sure)
3. Objects (line, arc, polyline, text, etc) - object are made only on layers
4. Object linking (Group, Toolpaths) - Groups and Toolpaths are linking or linked to objects and or Layers

Is this correct?

Do you know where I can get a layout?
Thanks,
Jim

jimandi5000

Posts: 30
Joined: Wed Mar 11, 2015 6:50 pm
Location: North Houston Tx.
Model of CNC Machine: Home Made 60 x 120

Re: How do you Group Objects on a Layer

I have done it!!!
Thanks,
Jim

jimandi5000

Posts: 30
Joined: Wed Mar 11, 2015 6:50 pm
Location: North Houston Tx.
Model of CNC Machine: Home Made 60 x 120