In the API, is there an equivalent to setting a part position with a numerical input?
Perhaps an oversight from me on using SetWorkPieceOrigin, since it only zeros the WCS, it doesn't seem to accept a part position value input?
I have an ultrasonic sensor that will detect X distance to the part along the track. So for each job segment, I will have an updated distance measurement in X (e.g. + 1.72 mm), and I want to set this as the new part position.Remotely trigger jobs using the API?
Moderator: cnckeith
-
- Posts: 91
- Joined: Wed Jan 26, 2022 4:53 pm
- Acorn CNC Controller: Yes
- Plasma CNC Controller: No
- AcornSix CNC Controller: Yes
- Allin1DC CNC Controller: No
- Hickory CNC Controller: No
- Oak CNC controller: No
- CNC Control System Serial Number: none
- DC3IOB: No
- CNC12: Yes
- CNC11: No
- CPU10 or CPU7: No
Re: Remotely trigger jobs using the API?
(Note: Liking will "up vote" a post in the search results helping others find good information faster)
-
- Web Developer
- Posts: 93
- Joined: Wed Oct 19, 2022 4:49 pm
- Acorn CNC Controller: Yes
- Allin1DC CNC Controller: Yes
- Oak CNC controller: Yes
- CNC Control System Serial Number: none
- DC3IOB: No
- CNC12: No
- CNC11: Yes
- CPU10 or CPU7: No
Re: Remotely trigger jobs using the API?
Currently there is no method or function for setting a part position using the API, we will try to add this functionality for the next release.johannes wrote: ↑Thu Dec 12, 2024 1:41 pm In the API, is there an equivalent to setting a part position with a numerical input?
Screenshot 2024-12-12 at 18.36.56.png
I have an ultrasonic sensor that will detect X distance to the part along the track. So for each job segment, I will have an updated distance measurement in X (e.g. + 1.72 mm), and I want to set this as the new part position.
Perhaps an oversight from me on using SetWorkPieceOrigin, since it only zeros the WCS, it doesn't seem to accept a part position value input?
However, you can use Job.RunCommand to call G92 and pass it your axis values. (Note: G92 sets the currently active WCS to the specified values)
Code: Select all
public bool SetAbsolutePosition(double? X = null, double? Y = null, double? Z = null)
{
string cmdText = "G92";
if(X.HasValue)
cmdText += $" X{X.Value}";
if (Y.HasValue)
cmdText += $" Y{Y.Value}";
if (Z.HasValue)
cmdText += $" Z{Z.Value}";
var cncJob = new Job (m_pipe);
if (cncJob.RunCommand(cmdText, GetCNC12WorkingDirectory(), false) == ReturnCode.SUCCESS)
{
return true;
}
return false;
}
Code: Select all
SetAbsolutePosition(1.72,null,null);
Code: Select all
cncJob.RunCommand("#2501 = 1.72; WCS #1 X val set to 1.72", GetCNC12WorkingDirectory(), false)
When requesting support please read this post first.
A fresh report makes it easier to assist you. To make a report check this post
A fresh report makes it easier to assist you. To make a report check this post
(Note: Liking will "up vote" a post in the search results helping others find good information faster)
-
- Posts: 91
- Joined: Wed Jan 26, 2022 4:53 pm
- Acorn CNC Controller: Yes
- Plasma CNC Controller: No
- AcornSix CNC Controller: Yes
- Allin1DC CNC Controller: No
- Hickory CNC Controller: No
- Oak CNC controller: No
- CNC Control System Serial Number: none
- DC3IOB: No
- CNC12: Yes
- CNC11: No
- CPU10 or CPU7: No
Re: Remotely trigger jobs using the API?
I went for this, it was clean and simple and worked fine. Thanks for sharing! This is exactly what I was looking for.Centroid_Jacob wrote: ↑Thu Dec 12, 2024 2:41 pm
Alternatively, you can use a similar approach and use RunCommand to set the system variables to the value if you need to change other WCS locations.
WCS Vars.png
Code: Select all
cncJob.RunCommand("#2501 = 1.72; WCS #1 X val set to 1.72", GetCNC12WorkingDirectory(), false)
(Note: Liking will "up vote" a post in the search results helping others find good information faster)