A small new script, Lengthen!

It’s a small script to position 2 vertices in a mesh, at the distance we define, keeping the orientation form each other.

Comments, please!

Tried it and it worked, well done. First script? Some suggestions…

  • Be good as a menu option
  • Report current on selecting second vert
  • Leave in edit mode (possible?)

I love precision tools! This is one that I didn’t even know I was missing.
As far as code goes, it’s not perfect, but it works. I do have a “feature request,” though. Could you also include a percentage setting? This would position the vertices according to a percentage of their original distance from each other.
Thanks!

Levi

I’ve made a few update.

It now can be moved to scripts folder (Mesh menu)
Report if the vertice 1 or 2 are selected (select 1 first, please)
It stays in Editmode
Indicates actual distance
New distance can be indicate as percentage

Thank you again, and if you have more ideas, i can try to implement them!

p.s. Certain calculations may give just 99,9999% of right value. I will investigate new formulas to minimize even more the redundant error.

MADCello, I did a re-write of your script. Everything works much better, in my opinion. You may not like the GUI (it’s a little cramped).

New features include:
Optional Fixation (point 1, point 2, or neither)
Points are not cleared after each “Apply”
Distance value is used for both normal and percentage calculations
Errors are displayed
Vertices can be selected from different objects (although it doesn’t do any object-space translations).
GUI is “shrinkable” (will match the size of a small window)
It’s very nearly bug-free, or at least I ran out of bugs to fix.

The only reason I’m posting this is so that you can get first dibs (I would’ve e-mailed it to you personally, but I don’t know the address). I don’t need any credit, and don’t want to take any away from you. I just needed to modify the script for my own uses, and decided to share the results.

http://members.isp.com/[email protected]/lengthen_add.py

If you want to put together some documentaion, and publish an official release, go ahead. It’s your script.

Levi

Be my guest!!

I’m making this scripts to learn a little of Python while producing something that i think it’s usefull.
I liked the new GUI, the option to fix none of the vertices and the option to chose vertices from diferent Meshes!!

p.s. i think that vertices from diferent meshes are not working very well. (few tests)

If you use percentage, i think it could be divided by 100, because if you put 50.0 you’re saying 50% (seems more logical, to me).

Now i have to study your code to learn a little more! Cool!

As you love precision tools, maybe you can check my first script (this one is my second) and please give me your opinion.
(link: http://pwp.netcabo.pt/0681373601/)

One error i already know is that i repeat the same code to many times, but with experience, i think i could (rentabilizar, dont know the word in english) get more juice from the code.

Nice Pythoning and Blending!!! :smiley:

p.s. i think that vertices from diferent meshes are not working very well. (few tests)

Yeah, like I said, it doesn’t translate the vertices to global coordinates. The functionality is there, however. All you have to do is set up the matrix multipliers for each object (which with Mathutils is pretty easy). I just didn’t take the time to do that.

I’ll have a look at the array script. I saw it when you first posted it, but I currently don’t have a specific need for that function.

Levi

GUI is “shrinkable” (will match the size of a small window)

Do you have any idea to write a adaptive GUI in some easy way? I have written one in ugly, no-reuseable sources.
That is to say:

  1. It is shrinkable as you said
  2. It fit both vertical and horizonal window
  3. The window can be devided into some parts, and the relative postion of every parts can be set respectively

For example, this kind of script runs in a horizonal window, and has 2 parts. The left one is a canvas, on which some shapes rest; the right contains some controller elements


+---------+-----------------------+
| +----+  | [btn1]         [btn2] |
| |    |  | [Num btn3]  =>slider<=|
| +----+  | [OK] [Exit]           |
+---------+-----------------------+    

the same script runs in a big vertical window. note that the canvas is up now to fit the whole window, and (of cause) every item is scaled.


+-----------------------------+
|  +-----------------------+  |
|  |                       |  |
|  |                       |  |
|  |                       |  |
|  |                       |  |
|  |                       |  |
|  |                       |  |
|  |                       |  |
|  |                       |  |
|  +-----------------------+  |
+-----------------------------+
|                             |
| [--------]       [--------] | 
| [  btn1  ]       [  btn2  ] | 
| [--------]       [--------] | 
|                             |
| [--------]                  | 
| [Num btn3]     =>>SLIDER<<= | 
| [--------]                  | 
|                             |
| [--------]   [--------]     | 
| [  OK    ]   [ Exit   ]     | 
| [--------]   [--------]     | 
|                             |
+-----------------------------+

As for the “relative postion”, do you know Tkinter for python(http://www.pythonware.com/library/tkinter/introduction/ in case no)? We can use S(South), E(ast), N, W, SW etc to locate an widgets coarsely; or for a N*M division, we use (row=1,column=2) and (rowspan=2,columnspan=3) to configure precisely. Thus we can have

Thanx

Do you have any idea to write a adaptive GUI in some easy way?

I suppose I do. Although it isn’t exactly elegant, and isn’t necessarily reusable. My technique is to determine certain “constants” (such as a standard button height, or a rectangle that certain buttons will fit in), use those constants in the Draw.YourButtonTypeHere() parameters, and make the “constants” relative to certain criteria (such as window height and width). Then, use a bunch of IF statements acting on the window width and height to set the constants. Make sense?

Study the script above. You’ll see that each button is not given an absolute y-coordinate, but one that depends of the variable ‘y’ (the border space) plus the variable ‘h’ (each button’s height) times the number of buttons below it (i.e. y+h*3). Like I said, it’s not elegant, but it works.

Levi

Yes, I programed in that way but I don’t like my current source style. Maybe I could coin some python class if I have the time.

Just another update.

http://members.isp.com/[email protected]/lengthen_add_015.py

Changes:

  • Vertices in different objects are correctly positioned
  • I found and fixed a bug (!)

Levi