<p>If the problem of &quot;dynamic area&quot;, or even &quot;how to avoid missing the surface and boundaries&quot; could be translated to &quot;where to start well-defined job&quot; - then it sounds to me like common task, with regards to philosophy of CNC machines. (Ok, until the surface is not moving around.)</p>
<p>Pronterface and GRBL work in Cartesain system. GRBL does not support mesh probing. So you must think about relatively flat, plane surfaces.</p>
<p>In my opinion, you need to fulfill following tasks to achieve the goal:</p>
<ul>
<li><strong>Define boundaries.</strong> Hard and soft boundaries of device are supported by GRBL. You should setup them for overall safety.</li>
<li><strong>Plan the job.</strong> Recognize ranges of planned plot or print.</li>
<li><strong>Secure the surface.</strong> It must be appropriately stabilized. If you want to draw, the pen mount with spring will equalize variations of the surface (hand, finger, <a href="https://www.thingiverse.com/tag:eggbot" rel="nofollow noreferrer">egg</a>). 3D printing is sensitive to roughness and obliquity, we add raft/supports to overcome these - could be of use, until it doesn't mean missing your goal? (Don't print with hot filaments on fingers.)</li>
<li><strong>Establish point of reference.</strong> You need to <a href="https://3dprinting.stackexchange.com/questions/8222/homing-the-3d-printer">home your plotting or printing head somewhere in space</a> in relation to the driving hardware. This is needed for any further actions. I envsion homing Z to the top of the frame, rather then against the target.</li>
<li><strong>Detect surface.</strong> Camera will help with horizontal borders (X,Y). You also need to measure the Z distance. The Z probe could be mechanical (then needs vertical movement) or some distance detector (like VL53L0X ?).</li>
<li><strong>Validate fitting.</strong> Ensure that the surface will accommodate ranges of planned job. This is actually the key point in my opinion. You need to know scope at the first place.</li>
<li><strong>Program.</strong> I see following options to pick and mix <strong>the final solution</strong> from them:
<ul>
<li>G-code is generated prior to the whole procedure. You need to synchronize the starting point between the generated file and the real job range. Homing is done &quot;manually&quot; prior to executing the file. After surface is detected, the real starting point could be calculated and applied.</li>
<li>G-code is generated after surface is detected. Job starts with homing, and first moves go from device's zero (home position) to selected starting point on the surface. All consecutive moves are planned within boundaries over the surface. So there is no risk to work outside the safe range.</li>
<li>G-code is generated with relative positioning (incremental distance mode), having <code>G91</code> in preamble. Then you just travel to the starting point and then run the commands from file.</li>
<li>G-code is generated with absolute positioning (absolute distance mode). To run the job, you need to change coordinate system using commands like <a href="https://github.com/gnea/grbl/wiki/Grbl-v1.1-Commands" rel="nofollow noreferrer"><code>G10</code>, <code>G54-G59</code></a>.</li>
<li>For printing, if there is a needed to match some flat shape to rought surface, then you may need to dynamically generate some supports/raft below the bottom of the printed part.</li>
</ul>
</li>
</ul>

CC BY-SA 4.0
2021-02-03T17:58:23.097Z
Hey octopus8. thanks for the answer. I was thinking about that what if I place 2 g-code images on pronterface plotting area. the first image is hand which is the boundary and the other image is design to print.[link](https://ibb.co/bWw1ZTD) this is image hope you understand
Tyson
CC BY-SA 4.0
2021-02-04T02:40:34.607Z
Be aware that G-code is not an image, but a set of instructions for printer. So it is "active" part. I am not sure of your plan, but if Pronterface will send both "star" and "cross" to printer, they will be both printed. For 100% you will not avoid develop new source code to make this project. So I would propose to modify this gray square grid in the background, instead increasing complexity by adding new "active" elements. Look for "def repaint_everything(self)" in "./printrun/gviz.py" - I am pretty sure this is the right place to start.
octopus8
CC BY-SA 4.0
2021-02-14T19:34:14.473Z
Hey octopus8. I hope you are fine. I just want to know that can we set the bed size in points. For Example I detect the object and place the object on graph and find all coordinate and set the coordinate as bed. I hope you understand.
Tyson
CC BY-SA 4.0
2021-02-15T20:55:05.933Z
I am afraid I am not... What kind of "points" do you mean? Probably not ["typography" points](https://en.wikipedia.org/wiki/Point_(typography))? So ...pixels on the screen? - then please read [How to convert millimeters to pixel?](https://graphicdesign.stackexchange.com/questions/25115/how-to-convert-millimeters-to-pixel) and [Calculating dots per...](https://graphicdesign.stackexchange.com/questions/80334/calculating-dots-per-pixel-when-printing-an-image?rq=1), because bed size is measured in real units, while pixels are relative to the display resolution and scaling.
octopus8
CC BY-SA 4.0
2021-02-19T10:30:21.703Z
points means x and y axis points. for example I detect object and plot the object on graph and get the points. now set my bed as graph points.
Tyson
CC BY-SA 4.0
2021-02-20T09:38:57.610Z
@Tyson, do you mean screen pixels? (math. "points" have no size!). And by graph you mean part of screen (grid in Pronterface)? If so, then all is about scaling. You need to be able to re-scale real dimensions (like millimeters) to screen dimensions (pixels). How many pixels is 1 cm in your "graph"? Therefore you have to know *real* dimensions of the surface subject (bed, finger, etc.) and thing to print. This is why you have to know Z distance, among others: to have data to calculate the real dimensions from a photo, and rescale to screen dimenstions, and then set your "size in points".
octopus8
CC BY-SA 4.0
2021-02-03T04:00:15.710Z
2021-02-03T04:00:15.710Z
octopus8
<p>I am trying to combine CNC plotter with image processing. The goal is to detect the object and print on that object. My question is can we set the fully dynamic plotting area.</p>
<p>For example: I want to print something on hand or finger. How do I tell the machine that this is hand and you have to print only on this hand.</p>
<p>I plan to detect the hand using a camera and set the hand as printing area in CNC firmware and the place G-code image on th finger. How to tell the CNC firmware that this is your printing area?</p>
<p>I am using GRBL firmware with Arduino and use Pronterface as software.</p>

CC BY-SA 4.0
2021-02-03T04:06:20.600Z
Hi Tyson! I have supplemented your queastion with information from comments. Could you review my answer if it is helping you, please? Also, we are not sure about your current G-code skills - and be aware that 3d printers focus on bit different set of commands than CNC machines (*arcs, where are you?*). Check the answer. Btw. I love your project, please leave a reference to your blog in comment :)
octopus8
<g-code><pronterface><cnc><plotter>
How to set the fully dynamic plotting area?
Tyson
# How to set the fully dynamic plotting area?

(Asked by: username_0 on 2021-02-02)

I am trying to combine CNC plotter with image processing. The goal is to detect the object and print on that object. My question is can we set the fully dynamic plotting area.

For example: I want to print something on hand or finger. How do I tell the machine that this is hand and you have to print only on this hand.

I plan to detect the hand using a camera and set the hand as printing area in CNC firmware and the place G-code image on th finger. How to tell the CNC firmware that this is your printing area?

I am using GRBL firmware with Arduino and use Pronterface as software.

**Tags:** g-code, pronterface, cnc, plotter

> **Comments:**
> **username_1**: Hi username_0! I have supplemented your queastion with information from comments. Could you review my answer if it is helping you, please? Also, we are not sure about your current G-code skills - and be aware that 3d printers focus on bit different set of commands than CNC machines (*arcs, where are you?*). Check the answer. Btw. I love your project, please leave a reference to your blog in comment :)  

---

## 1 answers

### Answer by username_1 on 2021-02-03. Score: 1

If the problem of "dynamic area", or even "how to avoid missing the surface and boundaries" could be translated to "where to start well-defined job" - then it sounds to me like common task, with regards to philosophy of CNC machines. (Ok, until the surface is not moving around.)

Pronterface and GRBL work in Cartesain system. GRBL does not support mesh probing. So you must think about relatively flat, plane surfaces.

In my opinion, you need to fulfill following tasks to achieve the goal:

* **Define boundaries.** Hard and soft boundaries of device are supported by GRBL. You should setup them for overall safety.
* **Plan the job.** Recognize ranges of planned plot or print.
* **Secure the surface.** It must be appropriately stabilized. If you want to draw, the pen mount with spring will equalize variations of the surface (hand, finger, [egg](https://www.thingiverse.com/tag:eggbot)). 3D printing is sensitive to roughness and obliquity, we add raft/supports to overcome these - could be of use, until it doesn't mean missing your goal? (Don't print with hot filaments on fingers.)
* **Establish point of reference.** You need to [home your plotting or printing head somewhere in space](https://3dprinting.stackexchange.com/questions/8222/homing-the-3d-printer) in relation to the driving hardware. This is needed for any further actions. I envsion homing Z to the top of the frame, rather then against the target.
* **Detect surface.** Camera will help with horizontal borders (X,Y). You also need to measure the Z distance. The Z probe could be mechanical (then needs vertical movement) or some distance detector (like VL53L0X ?).
* **Validate fitting.** Ensure that the surface will accommodate ranges of planned job. This is actually the key point in my opinion. You need to know scope at the first place.
* **Program.** I see following options to pick and mix **the final solution** from them:
  + G-code is generated prior to the whole procedure. You need to synchronize the starting point between the generated file and the real job range. Homing is done "manually" prior to executing the file. After surface is detected, the real starting point could be calculated and applied.
  + G-code is generated after surface is detected. Job starts with homing, and first moves go from device's zero (home position) to selected starting point on the surface. All consecutive moves are planned within boundaries over the surface. So there is no risk to work outside the safe range.
  + G-code is generated with relative positioning (incremental distance mode), having `G91` in preamble. Then you just travel to the starting point and then run the commands from file.
  + G-code is generated with absolute positioning (absolute distance mode). To run the job, you need to change coordinate system using commands like [`G10`, `G54-G59`](https://github.com/gnea/grbl/wiki/Grbl-v1.1-Commands).
  + For printing, if there is a needed to match some flat shape to rought surface, then you may need to dynamically generate some supports/raft below the bottom of the printed part.

> **Comments:**
> **username_0**: Hey username_1. thanks for the answer. I was thinking about that what if I place 2 g-code images on pronterface plotting area. the first image is hand which is the boundary and the other image is design to print.[link](https://ibb.co/bWw1ZTD) this is image hope you understand  
> **username_1**: Be aware that G-code is not an image, but a set of instructions for printer. So it is "active" part. I am not sure of your plan, but if Pronterface will send both "star" and "cross" to printer, they will be both printed. For 100% you will not avoid develop new source code to make this project. So I would propose to modify this gray square grid in the background, instead increasing complexity by adding new "active" elements. Look for "def repaint_everything(self)" in "./printrun/gviz.py" - I am pretty sure this is the right place to start.  
> **username_0**: Hey username_1. I hope you are fine. I just want to know that can we set the bed size in points. For Example I detect the object and place the object on graph and find all coordinate and set the coordinate as bed. I hope you understand.  
> **username_1**: I am afraid I am not... What kind of "points" do you mean? Probably not ["typography" points](https://en.wikipedia.org/wiki/Point_(typography))? So ...pixels on the screen? - then please read [How to convert millimeters to pixel?](https://graphicdesign.stackexchange.com/questions/25115/how-to-convert-millimeters-to-pixel) and [Calculating dots per...](https://graphicdesign.stackexchange.com/questions/80334/calculating-dots-per-pixel-when-printing-an-image?rq=1), because bed size is measured in real units, while pixels are relative to the display resolution and scaling.  
> **username_0**: points means x and y axis points. for example I detect object and plot the object on graph and get the points. now set my bed as graph points.  
> **username_1**: @username_0, do you mean screen pixels? (math. "points" have no size!). And by graph you mean part of screen (grid in Pronterface)? If so, then all is about scaling. You need to be able to re-scale real dimensions (like millimeters) to screen dimensions (pixels). How many pixels is 1 cm in your "graph"? Therefore you have to know *real* dimensions of the surface subject (bed, finger, etc.) and thing to print. This is why you have to know Z distance, among others: to have data to calculate the real dimensions from a photo, and rescale to screen dimenstions, and then set your "size in points".  

---

