How do you Group Objects on a Layer

This section is for general discussion about Gadgets
Post Reply
User avatar
jimandi5000
Vectric Wizard
Posts: 1050
Joined: Wed Mar 11, 2015 6:50 pm
Model of CNC Machine: Home Made 60 x 120
Location: North Houston Tx.
Contact:

How do you Group Objects on a Layer

Post by jimandi5000 »

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
DisplayMessageBox("No job loaded")
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)
layer:AddObject(CreateCadContour(line), true)

line = Contour(0.0)
line:AppendPoint(pt6)
line:ArcTo(pt7, 1.0)
line:ArcTo(pt6, 1.0)
layer:AddObject(CreateCadContour(line), true)

-- Group all on Layer "A"

job:Refresh2DView()
return true
end
Thanks,
Jim

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

Re: How do you Group Objects on a Layer

Post by Adrian »

Iterate through the layer and add to the group.

User avatar
jimandi5000
Vectric Wizard
Posts: 1050
Joined: Wed Mar 11, 2015 6:50 pm
Model of CNC Machine: Home Made 60 x 120
Location: North Houston Tx.
Contact:

Re: How do you Group Objects on a Layer

Post by jimandi5000 »

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

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

Re: How do you Group Objects on a Layer

Post by Adrian »

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

User avatar
jimandi5000
Vectric Wizard
Posts: 1050
Joined: Wed Mar 11, 2015 6:50 pm
Model of CNC Machine: Home Made 60 x 120
Location: North Houston Tx.
Contact:

Re: How do you Group Objects on a Layer

Post by jimandi5000 »

Hi Adrian,

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

User avatar
jimandi5000
Vectric Wizard
Posts: 1050
Joined: Wed Mar 11, 2015 6:50 pm
Model of CNC Machine: Home Made 60 x 120
Location: North Houston Tx.
Contact:

Re: How do you Group Objects on a Layer

Post by jimandi5000 »

I have done it!!! :D
Thanks,
Jim

zoner
Posts: 18
Joined: Wed Sep 11, 2013 6:41 pm
Model of CNC Machine: Self design - 5' x 10' x 1'

Re: How do you Group Objects on a Layer

Post by zoner »

Could you post the code that done it ? It owuld be appreciated :)

Post Reply