Programming question

This section is for general discussion about Gadgets
Post Reply
mcj
Posts: 4
Joined: Mon Dec 15, 2014 10:56 pm
Model of CNC Machine: ShopBot Alpha

Programming question

Post by mcj »

Hello all,
I hope this is the right place to post this question and that someone can help me with this.

I am trying to write a LUA script to batch process a bunch of my companies existing CRV files. I am new to VCarve and LUA, but have moderate programming knowledge. Most of my script is already written, however, there is one process that I am unsure how to complete or if it is possible. All of the CRV files currently have toolpaths that were created from imported vectors. What I would like to do is select the vectors based on a few properties like the cutdepth, bit and the toolpath type. The toolpath and bit type was the easiest, but apparently the cut depth isn't a property of the toolpath constructor that you can call. My thought on this is to use the tool constructor to create tools with the depths that we know exists and check those using the ":iscompatiblecutdepths()" method. Is there another way to do this that I am not seeing in the documentation? For example, if I already have 2 Profile and 1 Pocket created, is there an easier way to just access their cutdepth property/value?

I am also trying to select the vectors associated with these toolpaths and place them on a specific layer. Is this possible? I don't quite understand the selection methods in the documentation. I can see that there is a geometryselector object that has a ":loadselectordata()" method for toolpaths. How do you actually select the data/vectors associated with these toolpaths after running this method? Or is there another way that you have to do this? Or is this even possible? I tried going through the documentation but some of it isn't all that clear to me.

I would really appreciate any help on this subject. As I said, most of the script is already written, I just need to figure out how to select the vectors associated with a toolpath and place them on a specific layer.
Thanks guys.

User avatar
FixitMike
Vectric Wizard
Posts: 2177
Joined: Sun Apr 17, 2011 5:21 am
Model of CNC Machine: Shark Pro Plus (retired)
Location: Burien, WA USA

Re: Programming question

Post by FixitMike »

"I just need to figure out how to select the vectors associated with a toolpath...."

I don't know lua programming, but this may help.

If you double click on a toolpath in the Toolpath List, the associated vectors are selected, and can be cut or copied if they are visible. Or just right click on a selected vector and select Move to Layer from the resulting window. This will even move vectors not on visible layers to the selected layer.

Edit: Note: One has to close the Toolpath window before the selected vectors can be cut or copied.
Good judgement comes from experience.
Experience comes from bad judgement.

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

Re: Programming question

Post by Adrian »

Not sure what the end goal is but have you looked at toolpath templates? That feature will create toolpaths that automatically link to vectors on layers and can have variable depths etc based on calculated fields. All of that can be done without using LUA.

It sounds a bit like you're approaching the same solution from the other end.

mcj
Posts: 4
Joined: Mon Dec 15, 2014 10:56 pm
Model of CNC Machine: ShopBot Alpha

Re: Programming question

Post by mcj »

There are hundreds of CRV files that need to be processed in this manner. Scripting will make the process take a few minutes as opposed to weeks. The latter also resulting in taking someone off of their daily tasks for the amount it times to clean up these CRV files. So using the interface and having manual interaction is not an option we want to pursue if we don't have to. Our CRV files are already setup with toolpaths, so all we need to do is organize them.

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

Re: Programming question

Post by Adrian »

The GeometrySelectorObject is essentially the LUA equivalent of the Vector Selection part of the toolpath form. If the toolpath wasn't created with that then there will be no data in the object.

As far as I'm aware there's no way with the interface to go from an existing toolpath back to the manually selected vectors that were used to create it.

mcj
Posts: 4
Joined: Mon Dec 15, 2014 10:56 pm
Model of CNC Machine: ShopBot Alpha

Re: Programming question

Post by mcj »

When running tests, I called the "hasselectordata()" method on my existing toolpaths and it returns true, so there should be selector data stored with my toolpaths, right? Am I misunderstanding this? What exactly is the selector data that these methods return? When I click on the toolpaths in the toolpath list ui it selects the associated vectors. I just need to figure out how to do that and place them on layers through the LUA script.

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

Re: Programming question

Post by Adrian »

Not everything that is possible in the UI is possible in LUA. It certainly seems like what you want to do should be possible but I'm not aware of anyone else who has programmed in that particular area yet (unless Paul has done it) so you're pretty much the pioneer as far as knowledge goes!

The way I read it is that the LoadSelectorData only works to pass to another toolpath (via GeometrySelector) rather than creating any sort of vector object.

PaulRowntree
Vectric Wizard
Posts: 1687
Joined: Sun Oct 24, 2010 7:28 pm
Model of CNC Machine: homebuilt 4'x2' (Mach3+G540)
Location: Guelph, Ontario
Contact:

Re: Programming question

Post by PaulRowntree »

As far as I know, the Lua access to toolpath information is limited by design. I have never used the selectors myself, so I'm no use there either, sorry!

Can you say what you want to do with the toolpaths once you identify them?
Paul Rowntree
WarpDriver, StandingWave, Topo and gadgets available at PaulRowntree.weebly.com

User avatar
BrianM
Vectric Staff
Posts: 1964
Joined: Mon May 16, 2005 10:15 am
Model of CNC Machine: A few ...
Location: Alcester U.K
Contact:

Re: Programming question

Post by BrianM »

Hi,

I am also trying to select the vectors associated with these toolpaths and place them on a specific layer.
There is a method on the ToolpathManager object called RecalculateToolpath. As part of this process the vectors associated with the toolpath are selected and should be accessible via the Selection object after the toolpath has calculated. You could then move the vectors to a layer of your choice (you need to remove them from their original layer before adding them to the new one).

Read the warning in the documentation on RecalulateToolpath carefully if you still want access to the toolpath after calculating.
but apparently the cut depth isn't a property of the toolpath constructor that you can call
There is no current way of getting back data on a toolpath which was not calculated via the Lua interface. If you were creating the toolpaths via Lua, you could store the data you want as parameters on the toolpath (the toolpath is derived from utParameterList like CadObject so has the same Get / Set String/Bool/Double/Int methods as CadObject).

Brian

mcj
Posts: 4
Joined: Mon Dec 15, 2014 10:56 pm
Model of CNC Machine: ShopBot Alpha

Re: Programming question

Post by mcj »

The recalculate toolpath is exactly what I need to put the vectors on the layers.

So it seems like the only issue that I may not be able to solve is that of getting the current cut depth information? Can you think of any way to get that data? Can I use the ":SaveToolpathAsTemplate" and load or access the template files data? Would that be considered creating it using LUA? It looks like the template file would have to store the cut depth, but the file itself looks encrypted? So I can't run any checks on the file itself. What if I recalculate the toolpath using the recalculatetoolpath method, will the cut depth be exposed in any way that I can access it? Is there any use for the ":IsCompatibleCutDepths()" method?

I really appreciate all the help so far. If I could just get this last problem sorted, I'd be good to go.

Post Reply