Making an Add-on for Precision Drawing Tools (CAD)

I looked in the Docs and found something, so I tried this:

class precision_draw_tools_cm(Operator):
    """Precision Drawing Tools"""
    bl_idname = "pdt.precision_draw_tools_cm"
    bl_label = "Precison Drawing Tools"
    bl_options = {'REGISTER', 'UNDO'}
#etc..

# Registration
addon_keymaps = []

def register():
    bpy.utils.register_class(precision_draw_tools_cm)
    bpy.types.VIEW3D_MT_edit_mesh_vertices.append(draw_menu)
    # handle the keymap
    wm = bpy.context.window_manager
    # Note that in background mode (no GUI available), keyconfigs are not available either,
    # so we have to check this to avoid nasty errors in background case.
    kc = wm.keyconfigs.addon
    if kc:
        km = wm.keyconfigs.addon.keymaps.new(name='Edit Mode', space_type='EMPTY')
        kmi = km.keymap_items.new(precision_draw_tools_cm.bl_idname, 'P', 'PRESS', ctrl=False, shift=True)
        addon_keymaps.append((km, kmi))

def unregister():
    # handle the keymap
    for km, kmi in addon_keymaps:
        km.keymap_items.remove(kmi)
    addon_keymaps.clear()
    bpy.utils.unregister_class(precision_draw_tools_cm)
    bpy.types.VIEW3D_MT_edit_mesh_vertices.remove(draw_menu)

if __name__ == "__main__":
    register()

Don’t know what I did wrong… Does anyone have any ideas?

Cheers, Clock.

That does look better! And I like that the buttons use the full width with that mode. But I think for “Control Mode” there are too many settings to have the options expanded. It’s cool to see your progress making all this more intuitive.

1 Like

Thanks! :grin: I agree, I would like to have these options on two lines (but I don’t think you can do that), or I will have to go back to “not expanded” I think, or I need to make the dialogue wider, but I cant find how to do that…

So here it is with the Controls not expanded:

29

Showing all options:

36

I think this is better than having all 8 across the dialogue? It still works as well for me as a user like this, but I am a bit biased. :rofl:

Cheers, Clock. :cocktail:

EDIT:

Having said that, is this even better - changing mode now only rrequires one click rather than two:

04

2 Likes

It didn’t quite work how I planned as there are two rows of options, so I had to put a “dead” option on the first row so the code used the second row, not sure I like this, maybe someone else could advise on layout, I am a bit out of my depth with add-ons… So this is how it looks now:

13

I will think on some more about what to do with it. I still cannot get the hotkey assigned, that bit is baffling me, does someone have a pointer for me here? I guess I must give up on setting the dialogue width, everything I try either does nothing or stops it working!

Cheers, Clock.

1 Like

hei @clockmender
I had an idea …
Do you think it would be too complex to add visual measurement tools?
In your opinion would it be feasible or would it be better if blender had a set of APIs that would allow this kind of functionality?
I reason about this because actually they should be neither lines nor objects that are part of a mesh but rather something like measurement and visual help tools.

1 Like

Do you mean dimension like on a proper technical drawing that can be printed? Like this:

36

If so I think it is a brilliant idea, I have used the measure tool in Blender 2.8, but it doesn’t work as I would like and is a bit “weird” in operation to a draughtsman. See below:

10

They also disappear when you select another tool. However, the basic building blocks of code must be there for someone to develop into perhaps a new type of object (a “Dimensions” object) that consists of lines and text and will print… On that subject it would be nice if we could print line drawings, without using grease pencil, has that ever been looked at? Edge loops not made into faces do not render AFAIK.

I had considered adding a set of measure tools to my CAD functions, so you could measure the length between two vertices and set this as the “Delta” distance for example. It is very useful to be able to look at an object and say, “How far apart are these points” and use that to extrude another point the same amount. Even taking two points that are not on the X-Z plane but use their length on the X-Z plane to extrude another vertex - I may have to make a picture to explain that! This is a very necessary feature, my routines already do this to measure apparent angles of edges sloped in all axes on a global plane, like X-Z.

This line at the back is not planar to X-Z, but its angle in the front view relative to the X axis was used to draw the highlighted edge, which is planar to X-Z, making a flat face:

03

It is definitely feasible to have these tools, using Numpy routines to measure lengths and angles is quite straightforward, very powerful and very efficient in terms of computing time.

What is the level of support within BF for these developments, it would be a bit disappointing to do a shed load of work only for it to be “lost”.

Cheers, Clock.

5 Likes

exactly.

but I’d like something more “pre-set”, that with a simple click would show you the size of an object or a segment, or an angle …
I know that perhaps I ask too much ^ ___ ^ and that perhaps they are instruments that should be expanded to the level of core developing @mano-wii

:+1:

1 Like

At the moment, I can select two vertices and measure their angles in all three global planes with one click of my mouse button, I see now reason why I cannot select two vertices and measure their apparent lengths on all three planes and their actual distance apart in space just the same.

From a CAD perspective, to dimension a drawing I would simply select two vertices, click the “Length Dimension” tool and it would add all the lines and text in one operation, or I can select two edges, click the “Angle Dimension” tool and it will add all the lines and text showing their separation angle. Putting dimensions on a model must be quick and easy, it can be so in Blender, but the tools available now are “not quite there yet” for a draughtsman. If there is support for this to be done, I will either do it, or help with it, but we would need to come up with an object that can take both Edges and Text.

Cheers, Clock.

1 Like

Hi Clock! yes I can do that (I like talking to myself - sometimes it’s the only way to get a decent answer :rofl:):

24

The node now measures the apparent length between the two vertices in any Global plane, or their separation in 3D space. The “Dis 2” and “Dis 3” Functions also fill in the X, Y & Z boxes with the X, Y & Z offsets between the Active vertex and the Other vertex. You can see here that the other vertex is offset 4 in X, 2 in Y and 3 in Z (making a 3-4-5 triangle in the front view) with a 3D length of 5.38516 (not shown in the dialogue as it is in Working Plane Mode). So you can measure with the dialogue to set the values for coords and distance as well as the angle.

I still cant get the “hotkey” to work… grrrrr!

Cheers, Clock. :cocktail:

EDIT: here is the 3D measurement shown:

45

1 Like

as I understand it, you’re developing a set of tools that help construct objects through precise parametric commands …
and this is a good thing …
but what about the reverse process?
construct objects through the drawing that have precise dimensions …

did you see the np station tool?
you could take a look at the code, maybe he can give you some ideas …
:slight_smile: :wink:

1 Like

Have u used the CAD tools before, cause I think that anyone who has used cad tools for even a day might be knowing what these are (i am NOT rude anyway, just pointing out that its not too un-intuitive at all, rather is a standard).

Okay, anyways, absolute mode means that the next point is with respect to world origins, and the delta, or incremental mode means that the next point is in relation/with respect to the previous point.

yes, often.

but my aim is to bring people coming from polygonal modeling to precision modeling.
therefore it is necessary to level up “the standard” with a simplification that makes life easy even for ordinary people.

Can I just say; Absolute and Delta, or Incremental, are terms that CAD operators are very familiar with, but we must not forget that we are trying to encourage CAD operators to switch to Blender, so must make that easy. We are also trying to switch Blender modellers to precision CAD techniques, so they can model more accurately and easily, so we must tread a cautious line here to satisfy both parties. I am all for educating polygon modellers to use CAD terms, but I see the need to make it easy for them to adjust, so these tools are universally accepted, to that end I do not mind if we find some common terms, or a way of using both sets of terms in maybe the “Tooltips”, etc.

Meanwhile, I have modded the Add-on so it also works in Object Mode, using objects to drive the functions rather than vertices:

Here I have placed the cursor at the point where the active object would be normal to the other two.

Certain things won’t work of course, like Extrude, or Place Vert, or Join 2 Verts - there is an example of me “stating the bleeding obvious”… However, there is one issue that I cannot resolve and that is to use the Intersect commands as I don’t know in what order the selection of the objects was made. For vertices there is a select_history, for Objects there is not. As far as I can tell even in 2.8 Official, you cannot tell the order in which objects where selected, So I blocked that option for now, but all the rest work fine.

I have also made it into a proper add-on stored in Blender addons directory and have solved the “Hotkey” issue, now SHIFT+P brings up the dialogue in both Edit and Object Modes - what a smartarse I am. :brain::rofl::joy:

Cheers, Clock. :cocktail:

EDIT:

Reading dimensions of a drawing used as a reference, now that would be good! You can enter them in the appropriate boxes by reading the drawing yourself, but that is probably not quite enough. I will investigate whether I can read dimensions from a DXF imported into Blender…

3 Likes

So, I just wanted to make a little challenge, if anyone is interested. Model the following please:

It doesn’t matter what the overall diameter is, or the length, I am just interested in the profile of the dimensioned bit, my overall diameter was 63mm, just to make it more awkward for me to make. Use only standard Blender and tell me how long it took. Permitted accuracy from mathematical true is 0.000001mm and no calculators are allowed. I would be very interested in how long it takes and how you would do it, so please let me know as much as possible of your process. I am a designer with CAD ingrained over many years, so it is interesting to see how a “Polygon Modeller” would approach this.

The reason for this strange request is that I am trying to optimally cover the Precision Modelling requirement for this type of construction and want to make sure I have got the function covered properly, so any help here would be gratefully received. If you would like to post the blend file, I can check the accuracy…

The dimensions were done with a very experimental method, although the text is not integrated yet, I still need an object that can hold edges and text.

Cheers, Clock. :crazy_face:

3 Likes

work starts to get serious here … heheh

if from what I understand, if @mano-wii will provide us with a set of visual helper measurement objects accessible via API, you addon devs will can have a lot of fun

1 Like

Certainly can! This will save me a shed load of work, but there is a proviso:

A Draughtsman need two inputs to add a dimension, the Point/Edges to be dimensioned and the direction and distance for the text done with a mouse click. They also need to set whether they are showing a global Axis dimension, or a dimension parallel to a slanted edge. I don’t think the measure tools cater for that yet?

Cheers, Clock.

It took my about 5 minutes, although I messed up the 4mm constraint and the right cutout ended up too deep.

It feels so silly but something the process of doing edge intersections is something I do a lot and the way I do it is by zooming in all the way and doing an edge slide until the center pixel of the vertex overlaps the line. I’m not sure if there’s a simple better way in Blender already, but I know this is being worked on as part of the snapping project and I can’t wait for it to make it in.

Another frustration I face a lot is the lack of measurement objects like you were saying. The existing measure tool only shows measurements when you’re in the active tool! I wish you luck in this project. I have to say though, one thing I’m worried about is the duplication of effort that can happen when this sort of essential work goes on in addons rather than master Blender. It’s so much harder to do it that way because projects seem to need a lot of momentum to get dev attention, but the ideal next step to me seems like CAD additions to master. This is something I’m passionate about too so hopefully I can help on this front soon.

1 Like

Thank you so much for replying. :grin:

Yes! been there, done that, but the accuracy is not 100% doing it this way and I got very frustrated at not being able to do it easily and quickly, :frowning_face: so some pictures:

35

Here I extrude the selected vertex 0.7 at 120 degrees using my PDT Extrude then I simply click PDT Intersect with the four vertices selected:

13

Trim/Extend Checkbox is selected, so the two nearest vertices to the intersect point are moved and de-duplicated forming a perfect 100% accurate intersect - in seconds. This is why I want these tools in Blender so we can ALL model accurately and quickly. Pressure here might work in time…

BTW, I have never found an accurate way to do this in Blender - only guessing when zoomed in a great deal, like you. But if anyone wants to prove me wrong, that would make me very happy. :joy:

As for adding measurements, I need this, you need this and so do many others and we want them to persist and print and be placed in accordance with good draughting techniques.

Cheers, Clock. :cocktail:

4 Likes

OK, question to the devs (suitable tugging of forelock):

Could we please have in Blender, soon:

  1. Ability to input a “delta” value when moving objects, or vertices, or extruding vertices, something like Select Object, key G D 0.1,0.3,0.4 to move an object 0.1 in X, 0.3 in Y and 0.4 in Z.
  2. Ability to input a Distance/Angle value when doing the same, something like Select Object, key G I 0,5,34 to move object 0.5 at 34 degrees in view plane.
  3. Ability to extend/trim two edges (or implied edge from two vertices) to their intersection, or place the cursor there.
  4. Ability to place cursor at the normal intersection between a vertex and an edge (or implied edge from two vertices), or move the active vertex to its normal intersection with an edge (or implied edge from two vertices)

Just four little things to make life so much easier for precision modellers. Please, pretty please! What are the chances of this?

Cheers, Clock. :cocktail:

PS I have done all the maths and logic to achieve this in Python.

I wouldn’t want to understand you need something totally different …
but currently you can set this through the modal operators …
select a vertex then press G then X then 0.3 then Enter for example …

to extrude:
select a vertex then E then X then 1.34 then Enter for example…

similar things for rotations …

edit:
I studied better …
yes it would be really nice what you ask :wink: