# Implementing a Locator for Graphics3D drawing tools for programmatic drawing

As a hobby I write from time to time some tools for programmatic technical drawing. Below I give an example of a function modifyGraphics[] which enables one to fast add an element to a 2D graphics, such as a line or some text that requires to choose and add some coordinates.

modifyGraphics[sketch_Graphics, pt10_, pt20_] :=
Column[{
Manipulate[
pp1 = pt1;
pp2 = pt2;
(* This is the beginning of the part to copy *)
Show[{

sketch,

(* This is the beginning of the element to add to the sketch *)

Graphics[{
Dashed, Line[{pt1, pt2}],
Text[Style["A", 16, Bold], pt1]
}]

(* This is the end of the element to add to the sketch *)
}]

(* This is the end of the part to copy *)

, {{pt1, pt10}, Locator,
Appearance ->
Graphics[{Red, Table[Circle[{0, 0}, i], {i, 3}]},
ImageSize -> 20]}, {{pt2, pt20}, Locator}],

Button["Get points", Clear[points]; points = {pp1, pp2}]
}]


sketch is a some 2D graphics (with the head Graphics). pt10 and pt20 are 2D initial coordinates of two locators. Say, pt1 may be equal to {0.3,0.5} and pt2 - to {0.7,0.5}, provided that the both points lay within the visible domain.

1. Copy-paste or type the necessary graphics element between the comments: (* This is the beginning of the element to add to the sketch ) and ( This is the end of the element to add to the sketch *) of the code.

2. Find the necessary position. For a simple 2D graphics:

modifyGraphics[Plot[x^2, {x, -1, 1}], {1/3, 1/2}, {2/3, 1/2}]


here is how it looks like on the screen

1. Press the button.

2. Evaluate a global variable points in a separate cell. Copy-paste the coordinates of the locators into the added element of the graphics.

3. Copy the code between the comments: (* This is the beginning of the part to copy ) and ( This is the end of the part to copy *) and paste it into your original input cell for the graphics Done.

I think the rest is self-explanatory, but I can add some more explanations upon request. This works. It is given here as an example of what I would like to achieve. However, Locator is an essentially 2D object, and I would like to also be able to modify Graphics3D objects.

Now comes my question:

Can we try to implement the same idea for modifying 3D objects, such as e.g., Plot3D?

• – Jens Jan 12 '17 at 21:39