Some questions about the Freehand Sketch tool
All  1-4  5-13

Previous
Next
 From:  Michael Gibson
9606.5 In reply to 9606.4 
Hi Pior,

re:
> Is there an official place somewhere listing all these script classes, and maybe even
> an inventory of useful commands like this one ?

There is a collection of scripts used in buttons in the help file here:
http://moi3d.com/3.0/docs/moi_command_reference11.htm#shortcutkeys

And there are some other frequently requested ones collected here:
http://kyticka.webzdarma.cz/3d/moi/


> This page could even be accessible directly from the Shortcut Keys option
> panel for instance.

In the future I would like to make an online "script repository" that would hold a bunch of scripts listed in different categories and have a browser for them built into MoI but there will be a lot of work involved in making that so I'm not sure when it will be able to happen.


> So naturally I'd be curious to know if there a way to call a complex command like this "sketch repeat"
> script from the html code. This is what I meant by appending it to a button, if that makes sense :)
> This would basically allow me to store custom commands without necessarily having to assign them
> to KB shortcuts.

Yes, on a <moi:CommandButton> element instead of having a command="commandname" attribute instead put in an onclick="" event handler attribute which can contain general script code. So for the sketch repeat it would look like this:
code:
<moi:CommandButton onclick="moi.ui.sidePane.RepeatCheckbox.value = true; moi.command.execCommand( 'SketchCurve' );">Button label</moi:CommandButton>

(Looks like you found that already...)

> Lastly a follow-up question on CPlane : is there a clever way to select a surface, then
> click a button/run a command and have the CPlane be instantly placed on there and
> aligned to said surface ? As opposed to having to launch CPlane and then picking the
> center point and setting the orientation manually each time.

A couple of v4 betas back there were some new methods added to faces that allow scripts to retrieve information on the face so it is possible to do that. Here's a script that will set the cplane to a selected planar face:

script: /* Set cplane to selected face */ var faces = moi.geometryDatabase.getSelectedObjects().getFaces(); if ( faces.length == 1 ) { var f = faces.item(0); if ( f.isPlanar ) { moi.view.setCPlane( f.planarFrame ); } }

Hope that helps!

- 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)
9606.6 In reply to 9606.5 
Quasi automatic CPplane
This last one is some cool! :)
  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)
9606.7 
PS
CPlane's Script above...Not Undoable ?

EDITED: 6 Dec 2019 by PILOU

  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
9606.8 In reply to 9606.7 
Hi Pilou, you can right-click on the View > CPlane button to reset the cplane to the default world location. Or if you want to have it on a shortcut key put:

script: moi.view.resetCPlane();

- 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)
9606.9 In reply to 9606.8 
Thx for the precision! ;)
Added to the French site :)
http://moiscript.weebly.com/plan-aux.html
  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
9606.10 In reply to 9606.7 
Hi Pilou, or this variation will work as a toggle, if you use the same shortcut a second time it should reset it:

script: /* Set cplane to selected face or reset on second use */ var faces = moi.geometryDatabase.getSelectedObjects().getFaces(); var was_set = false; if ( faces.length == 1 ) { var f = faces.item(0); var cp = moi.view.getCPlane(); var vm = moi.vectorMath; if ( f.isPlanar ) { var p = f.planarFrame; if ( !(vm.pointsAreEqual(p.origin,cp.origin) && vm.pointsAreEqual(p.xaxis,cp.xaxis) && vm.pointsAreEqual(p.yaxis,cp.yaxis)) ) { moi.view.setCPlane( p ); was_set = true; } } } if ( !was_set ) moi.view.resetCPlane();

- 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)
9606.11 In reply to 9606.10 
Excellent! Added! :)

EDITED: 6 Dec 2019 by PILOU

  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:  Marc (TELLIER)
9606.12 
Ooh, I like this script !
  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:  nameless
9606.13 In reply to 9606.10 
Perfect!
  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: All  1-4  5-13