Script for placing guitar frets

Next
 From:  Martin (MARTIN3D)
5440.1 
I was able to modify the CenterAtOrigin script to help modelling guitars.
The script places 24 frets at their correct locations for a scale length of 25.5”.
For a different scale length just change the number after “var scaleLength =“
Scale lengths must be entered in inches.

Instructions
- Copy the script below to the clipboard
- Open the attached MoI file
- Set Options > Unit System: Millimeters
- Select the fret
- Hit the TAB key
- Paste the script and hit ENTER



- Start the fretboard at the center of the first fret and delete the latter.


Cut the fretboard to the desired shape using Boolean Diff


script: var scaleLength = 25.5; var distanceFromNut = 0; var distanceToNextSlot; var fretslot; 
var objects = moi.geometryDatabase.getSelectedObjects(); 
var bbox = objects.getHighAccuracyBoundingBox(); var pt = bbox.center; var factory; 
for ( var i = 0; i < 24; i++ ) { distanceToNextSlot = (scaleLength * 25.4 - distanceFromNut) / 17.8171537451058; 
distanceFromNut += distanceToNextSlot; pt.x += distanceToNextSlot; factory = moi.command.createFactory( "copy" ); 
factory.setInput( 0, objects ); factory.setInput( 1, bbox.center ); factory.setInput( 2, pt ); factory.commit(); }

  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
5440.2 In reply to 5440.1 
Cool use of scripting Martin! - 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:  Martin (MARTIN3D)
5440.3 In reply to 5440.2 
That CenterAtOrigin script by you helped a lot.
Is it possible to draw something i.e. a line or a box via scripting?
  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
5440.4 In reply to 5440.3 
Hi Martin,

> Is it possible to draw something i.e. a line or a box via scripting?

It is, but all that kind of stuff is set up more for how the drawing commands work where you're picking things interactively in stages.

The way it works for a line for example is that you create a line "factory", set the values for its inputs and then the factory can generate an output. In the line command the inputs come from the results of a pointpicker.

In the future I want to add a more simplified interface for scripts with something like just a moi.geometryDatabase.createLine( start, end ) type call but that layer is not in place at the moment.

- 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
5440.5 In reply to 5440.3 
There's a plug-in here which creates lines which you might be able to use as an example:
http://moi3d.com/forum/index.php?webtag=MOI&msg=5136.1

- 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:  Martin (MARTIN3D)
5440.6 In reply to 5440.5 
Thanks 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:  Shaun (MOISHAUN)
5440.7 
Martin and Gibson. But where is Fender?
  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