Creating a circle with a gadget

This section is for general discussion about Gadgets
Post Reply
GrainDesign
Posts: 4
Joined: Thu Jun 16, 2016 8:05 am
Model of CNC Machine: Ascent pro

Creating a circle with a gadget

Post by GrainDesign »

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

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: Creating a circle with a gadget

Post by Adrian »

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

Chelmite
Posts: 23
Joined: Tue Nov 06, 2012 4:47 am
Model of CNC Machine: Legacy Maverick 4x8, BOSS laser
Location: Los Altos Hills, CA

Re: Creating a circle with a gadget

Post by Chelmite »

AddGroupToJob is not in the 10.5 SDK. How do I add the group to the job in 10.5?

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: Creating a circle with a gadget

Post by Adrian »

Chelmite wrote:
Fri Aug 14, 2020 9:18 am
AddGroupToJob is not in the 10.5 SDK. How do I add the group to the job in 10.5?
AddGroupToJob is a user defined function as shown in the code in the previous post. It's not part of the SDK. Just copy the code and put it into your code.

Chelmite
Posts: 23
Joined: Tue Nov 06, 2012 4:47 am
Model of CNC Machine: Legacy Maverick 4x8, BOSS laser
Location: Los Altos Hills, CA

Re: Creating a circle with a gadget

Post by Chelmite »

Thanks! I figured it out, but am unable to delete my question.

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

Re: Creating a circle with a gadget

Post by jimandi5000 »

GrainDesign wrote:
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
Hi GrandDesign,

Have you looked at a SKD Wiki I built?

https://jimandi.com/SDKWiki/index.php?title=Main_Page

I have code posted to help show how to draw with Gadgets. have a look at this one: https://jimandi.com/SDKWiki/index.php?t ... w_a_Circle

Let me know if you need help.
Thanks,
Jim

Post Reply