Creating a circle with a gadget

This section is for general discussion about Gadgets

Creating a circle with a gadget

Postby GrainDesign » Tue Dec 05, 2017 8:49 am

Hi there

I'm just learning how to create gadgets and was wondering what the easiest way of creating a circle within a gadget is.

I have tried to use the CreateCircle() global method but cant seem to get it to work it just keeps returning a nil value. (Maybe I'm doing something wrong)

Would it be easier to us the contour:ArcTo() method and us either 2 or 4 lines arced to make the circle.

any help would be appreciated.

thanks
GrainDesign
Vectric Apprentice
 
Posts: 4
Joined: Thu Jun 16, 2016 8:05 am
Model of CNC Machine: Ascent pro

Re: Creating a circle with a gadget

Postby Adrian » Tue Dec 05, 2017 10:13 am

This is a bit of code based on an example SDK script that draws a circle using CreateCircle.

Code: Select all
-- VECTRIC LUA SCRIPT

require "strict"

function AddGroupToJob(job, group, layer_name)

   local cad_object = CreateCadGroup(group);
   local layer = job.LayerManager:GetLayerWithName(layer_name)
 
   layer:AddObject(cad_object, true)
   
   return cad_object
end

function main()

    local job = VectricJob()
 
    if not job.Exists then
       DisplayMessageBox("No job loaded")
       return false; 
    end

   local group = ContourGroup(true)
   
   group:AddTail(CreateCircle(0,0,20,0.0,0.0))   
   AddGroupToJob(job, group, "Circle Example")       

   job:Refresh2DView()
   
   return true

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


Return to Gadgets - General

Who is online

Users browsing this forum: No registered users and 3 guests