Small Feature Wish
 1-5  6-21

Previous
Next
 From:  Kiril
3756.6 In reply to 3756.2 
I've done some web development so I know my way around html/css/javascript. Have been wishing to add some buttons to the interface :
1 - Join + Rebuild (Tolerance/Number) combination button
2 - Dedicated Boolean Buttons for Substract and Merge
3 - Select only 'compound' paths
4 - Work plane buttons that automatically align plane to selection and a button to reset it.
5 - Select Loop(all connected but un-joined paths)
Would you mind posting the some details how this might be done(the button addition part)?

Thanks,

Kiril
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
3756.7 In reply to 3756.6 
Hi Kiril,

> 1 - Join + Rebuild (Tolerance/Number) combination button

So you mean something like join on left-click and rebuild on right-click?

Where would you like this button to go, do you just want to add the right-click part to the existing Edit > Join button, or do you want a complete new button somewhere for this? (possibly on the bottom toolbar, there is usually a lot of space down there next to the grid and object snap buttons)


> 2 - Dedicated Boolean Buttons for Substract and Merge

Where would you want these?


> 3 - Select only 'compound' paths

You mean curves that are made up of more than 1 sub-segment? (that will break into multiple pieces when using Separate on them?)


> 4 - Work plane buttons that automatically align plane to
> selection and a button to reset it.
> 5 - Select Loop(all connected but un-joined paths)

These ones would require a lot more stuff than adding a button, it would require new code logic to also handle these. Probably these would not be feasible until MoI v3.


> Would you mind posting the some details how this might
> be done(the button addition part)?

Certainly, just give me a bit more info on where you want to put the buttons.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Kiril
3756.8 In reply to 3756.7 
Ans 1> I thought it might be possible to combine Join & Rebuild in a single left-click action - that is, after I've made my selection.
Is it actually possible to have a button respond differently to a right and left click?!(That would be very useful for minimizing button clutter).

Yes I planned to add all my custom buttons there("bottom toolbar").

Ans 2> re:bottom toolbar

Ans 3> Exactly right. While point editing, I often find myself unpleasantly surprised by, what at first seem continues stretches of a curve, spikes:


Ans 4&5> Thanks, that fact will save me the effort. I would still find it useful to pu the "Plane" button in said toolbar - left click = activate right click = reset(assuming this is possible).

Thanks,

Kiril

Edit: Just realized the Cplane button already resets the plane on right click! - that answers that.

EDITED: 14 Sep 2010 by KIRIL

Attachments:

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
3756.9 In reply to 3756.8 
> I thought it might be possible to combine Join & Rebuild
> in a single left-click action - that is, after I've made my
> selection.

Well, that could be possible but combining together actions like
that is somewhat more involved than just making a button, it would
probably involve making a new script command that combined elements
of both those commands together.


> Is it actually possible to have a button respond differently
> to a right and left click?!(That would be very useful for
> minimizing button clutter).

Yup, like you saw with View > CPlane it's possible to have that, it's just not
used in many places currently because it's hard to properly illustrate or describe
the 2 things instead of 1 thing, so it only fits naturally if the things are
pretty closely related.

The right-click is also used on Hide and Lock, where it does an "isolate" of
the selected objects (hiding everything else and leaving only the
selected stuff visible).

Ok, so, let's start with this one:
> 2 - Dedicated Boolean Buttons for Substract and Merge

So for this, go to the \ui sub-folder under MoI's main installation folder, and open
up the file CommandBar.htm in a text editor like notepad or whatever (probably
best not to use some fancy HTML editor as there are tags with custom names
that could get munched).

That file controls the bottom toolbar.

Go to the end of the body, and before the body end tag (just below the
<nobr> that contains the grid and object snap buttons), put in the following:

code:
<moi:CommandButton style="icon:icons/BooleanDifferenceIcon.png;" command="BooleanDifference"><moi:Text textid="BooleanDifference"/></moi:CommandButton>
<moi:CommandButton style="icon:icons/BooleanMergeIcon.png;" command="BooleanMerge"><moi:Text textid="BooleanMerge"/></moi:CommandButton>


With those in place, that will give you 2 new buttons to the right of the Object Snap
button on the bottom bar, for doing boolean difference and boolean merge, pushing
those will be the same as going to Construct > Boolean > ...

By the way the attribute that controls what command is launched is the command=""
part, and if you want a right-click command you can put that on the
button as an rcommand="" attribute.


> 3 - Select only 'compound' paths

Ok, this one does not have a pre-made command for it already, instead it needs to run
some script, so put in this button for it:

code:
<moi:CommandButton onbuttonclick="var crvs = moi.geometryDatabase.getObjects().getCurves(); for ( var i = 0; i < crvs.length; ++i ) { var crv = crvs.item(i); if ( crv.getSubObjects().length > 1 ) crv.selected = true; }">SelPath</moi:CommandButton>


Let me know if that does not work like you want.

If you cook up an icon for it, you can copy that to the \ui\icons folder and then declare it
in the style as the above buttons.


- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
3756.10 In reply to 3756.8 
Oops, missed this one:

> I would still find it useful to pu the "Plane" button
> in said toolbar - left click = activate right click =
> reset(assuming this is possible).

For this one, open up the file SidePane.htm, that contains all the palettes of stuff on the right-hand side, then go to the cplane button (search for the text CPlane, it's on line #617) and copy out the <moi:CommandButton> for it, paste that into the end of the CommandBar.htm file and you'll have the cplane button down there on the bottom.

You can move other buttons over the same way. Some buttons are part of a "command set", like the little booleans menu thing, those buttons are actually in small .htm files in the \commands sub-folder, like the boolean menu is in the file Booleans.htm in that commands folder, the buttons for the individual boolean commands are in there.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
3756.11 In reply to 3756.10 
Does this sort of moves buttons will be more easy in the V 3?
An easy "building interface" by the advanced user or modeling functions are more priority?
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
3756.12 In reply to 3756.11 
Hi Pilou, I think that some easier UI configuration stuff will get some attention in v3, but it remains to be seen how much exactly.

I don't think I'm going to try to do a "drag/drop" type arrangement of buttons but instead have something like a UI organization dialog type thing. No totally set plans yet though.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Kiril
3756.13 In reply to 3756.9 
The script works perfectly Michael, also thanks for taking the time to explain the procedure of adding buttons.

I've managed to implement the buttons I wanted:


I did make an attempt at combining Join and Rebuild in a single click, thinking that I could stuff the "DoRebuild()" and "DoJoin()" functions together in a new function Joinrebuild.js
and call that as a command - but did not work out - so left click = Join & Right click = Rebuild.

In the spirit of learning and trying to understand MoI scripting I analyzed your script and annotated its working with comments - first for myself and now for anyone else interested:

Get all curves in the workspace, store them in the array 'crvs'.
var crvs = moi.geometryDatabase.getObjects().getCurves(); 


Look at each curve in the scene, incrementally, where curvs.length refers to the number of curves in the array 'crvs'.:
for ( var i = 0; i < crvs.length; ++i ){	


Get the item(which itself is an array) in the array 'crvs' in position 'i''(a digit set by the previous declaration)(array entries are numbered from 0, so i=0 makes sense).
var crv = crvs.item(i); 


Assuming a compound curve is a single entry in the 'crvs' array, look at the 'SubObjects' property of that curve(an array) - specifically its 'length' or number of entries.Since a compound path will contain multiple sub-curves/"[..]objects" we would expect length to be>1 - in this case select it.
if ( crv.getSubObjects().length > 1 ) crv.selected = true; }


Regards,

Kiril

EDITED: 15 Sep 2010 by KIRIL

Image Attachments:
Size: 20.8 KB, Downloaded: 49 times, Dimensions: 505x92px
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
3756.14 
"Select only 'compound' paths" can
be put on a shortcut?

If Yes what is the syntax?
---
Pilou
Is beautiful that please without concept!
My Gallery
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Kiril
3756.15 In reply to 3756.14 
Hi Pilou,

It suffices to follow the normal method of adding a shortcut, and adding:

script:var crvs = moi.geometryDatabase.getObjects().getCurves(); for ( var i = 0; i < crvs.length; ++i ) { var crv = crvs.item(i); if ( crv.getSubObjects().length> 1 ) crv.selected = true; }

With all credit for the script given to Michael, ofcourse.
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
3756.16 In reply to 3756.15 
Thx, it was for the end of the line that I had some doubt :)
---
Pilou
Is beautiful that please without concept!
My Gallery
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
3756.17 In reply to 3756.16 
there is not something false in the script?
Seems it keep in memory previous joined lines!

If I launch the script whith the yellow curves selected, the other curve becomes yellow too !!!
Is that normal?

EDITED: 15 Sep 2010 by PILOU

Attachments:

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Kiril
3756.18 In reply to 3756.17 
I've made a small change to the script that will clear all previous selection and then proceed to look for only compound curves:
code:
moi.geometryDatabase.deselectAll(); var crvs = moi.geometryDatabase.getObjects().getCurves(); for ( var i = 0; i < crvs.length; ++i ) { var crv = crvs.item(i); if ( crv.getSubObjects().length> 1 ) crv.selected = true; }

This is actually a good idea, since it will avoid mistaken identification.

Confusion may also arise after having used the "Rebuild" function with the "Refit" option. In this mode only curviture continuous stretches of a compound curve are rebuilt into a single entity; this results in the possibility of a compound curve even after a "rebuild". To avoid this use the "# points" option("keep corners" turned off); since this mode is not adaptive you will need many points - by running the rebuild function a second time, with the "Refit" option, this problem can be avoided.

If your asking why "previous joined lines" are selected: this is the purpose of the script :) - the idea is to select these charlatans :) and 'rebuild' them, this way avoiding spikes/kinks while editing.
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
3756.19 In reply to 3756.18 
<this way avoiding spikes/kinks while editing.
I had well understood :) but not for the curves who are some kilometers away :)
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
3756.20 In reply to 3756.18 
Hi Kiril, also if you want more info about scripting, one way is to look at existing scripts but also see here:
http://moi3d.com/wiki/Scripting

for some additional information. See David's page for some documentation on what properties and methods are available on each MoI class, and also you can get the moi.idl file there which contains a all the stuff that is accessible to scripting in it.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  Kiril
3756.21 In reply to 3756.20 
Thanks Micheal, I'm quite content with the level of customization I can achieve now - I shall wait for something akin to JQuery for MoI :) before I invest much more time into scripting.

Cheers,

Kiril
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All

 

 
 
Show messages:  1-5  6-21