MoI discussion forum
MoI discussion forum

Full Version: [script] FxGraph - 2D/3D Function plotter

Show messages:  1-9  10-29  30-49  50-69  70-89  90-91

From: Max Smirnov (SMIRNOV)
17 Apr 2016   [#30]
While writing Math nodes for my nodeedit project, I found one significant bug in the FxGraph/3D code. The script incorrectly processes a square brackets and "rnd" command in some cases.
Updated scripts:
http://moi.maxsm.net/media/files/FxGraph3D.v.1.1.2016.04.17.zip
http://moi.maxsm.net/media/files/FxGraph.v.1.2e.2016.04.17.zip
From: bemfarmer
22 Jul 2017   [#31]
While exploring Scherk2 minimal surface, and hyperbola, these shapes came up:

sinhLeaf:
_FxGraph3D u;v;((exp(u) - exp((-1)*u))/2 + (exp(v) - exp((-1)*v))/2);-3.14159;3.14159;-3.14159;3.14159;15;15;0;0;0;UV

sinhcoshScoop:
_FxGraph3D u;v;((exp(u) - exp((-1)*u))/2 + (exp(v) + exp((-1)*v))/2);-3.14159;3.14159;-3.14159;3.14159;15;15;;;;UV

coshBag:
_FxGraph3D u;v;((exp(u) + exp((-1)*u))/2 + (exp(v) + exp((-1)*v))/2);-3.14159;3.14159;-3.14159;3.14159;15;15;;;;UV

The scripts can be stored in a notepad++ text file.

To repeat how to view in MoI, with Max's _FXGraph3D script already installed, highlight one entire line, press Ctrl+C.
Open MoI, press TAB, press Ctrl+V, press Enter.
Network can be used to make a quick surface.

- Brian
From: TOM (SIRTOM)
23 Jul 2017   [#32] In reply to [#31]
Beautyful - did not know about that cpoy+paste function !
From: bemfarmer
23 Jul 2017   [#33]
This script is called BowTie.
_FxGraph3D v*sin(u);v*cos(u);a * asin(((exp(u*sin(v)) - exp(-u*sin(v)))/2) * ((exp(u*cos(v)) + exp(-u*cos(v)))/2));-0.8;0.8;-3.14159;3.14159;15;15;1;;;UV

Selecting just the U iso curves, allows trim with a point at the origin.
Each bow will then network at the 15 curve density.
Each surface can be extruded slightly and the fillet applied.

- Brian
From: Mike (MGG942)
24 Jul 2017   [#34] In reply to [#33]
Nice - except I've not been able to make a surface.

Would you mind splitting this: "Selecting just the U iso curves, allows trim with a point at the origin." into a number of discrete steps?

My particular confusion is what to trim with what, and what to delete (or not).

Mike.
From: bemfarmer
24 Jul 2017   [#35] In reply to [#34]
Hi Mike,
Network does not always work on such complete structures, but may work with portions.
(Having a lot more U and V curves may prevent Network from working.)

After creating the UV curves,
1. Place a point at the origin. This is not essential, but helps locating the origin.
2. Select only the curves passing through the origin.
These are the U curves, and could have been identified by previously running a separate U mode. (It is not essential to run a separate U mode.)
3. Run Trim command
4. Press "add trim points"
5. Select origin point as place to put the added trim point.
6. Press Done. (Do not press "remove curves" button.)
7. Press Done again. The two "lobes" are now separate.
8. Select both U and V curves for one entire lobe.
9. Press Network, which creates one lobe surface in half a second or so.
(Network does not work if both lobes UV lines are selected at the same time.)
10. The second lobe can also be Networked separately.

- Brian
From: BurrMan
24 Jul 2017   [#36]
Hi Michael,
With regard to these last "FXGraph" scripts posted here:

http://moi3d.com/forum/index.php?webtag=MOI&msg=6447.31

They work from entering the command in the command area. Is there a modification to it to call from a js file like a regular script? Or is a complete rewrite?
From: Michael Gibson
24 Jul 2017   [#37] In reply to [#36]
Hi Burr,

re:
> They work from entering the command in the command area. Is there a modification to it
> to call from a js file like a regular script? Or is a complete rewrite?

That's just one option that it can be run from the command area - the way Brian shows above runs the _FxGraph3D command but also gives it command line parameters. I think the _FxGraph3D command can also be run without any command line parameters too, that's just one way for it to initialize its UI.

- Michael
From: Mike (MGG942)
25 Jul 2017   [#38] In reply to [#35]
Many thanks, Brian.

The bit that tripped me up (I am now embarrassed to admit) was to attempt to Network both halves in one operation.
From: BurrMan
25 Jul 2017   [#39] In reply to [#37]
Hi Michael,
""""""""""" the way Brian shows above runs the _FxGraph3D command but also gives it command line parameters."""""""""""""""""

Yes. But can that work from a js file? Like is it just missing a "command execute" or something? How to make those parameters pass from the js file? (Without a big rewrite.)
From: Michael Gibson
25 Jul 2017   [#40] In reply to [#39]
Hi Burr, from what other .js file, do you have something like a launcher dialog you're setting up? You should be able to use moi.command.execCommand(); to do the same thing, it should support command line parameters just make sure there is a space between the command name and the parameters in the string you send to moi.command.execCommand() same as in the pasted in text.

- Michael
From: BurrMan
26 Jul 2017   [#41] In reply to [#40]
Hi michael,
No, i have no file i was working on. I just put the scripts from the forum in js files as opposed to shortcuts. This particular "command" didnt work from a js file.

Can you give me a quick example of using the moi.command.execCommand()?

I was looking to just put these last fxgraph (with parameters) scripts into named js files so i can call them that way.
From: Michael Gibson
26 Jul 2017   [#42] In reply to [#41]
Hi Burr, sure - so the first one that Brian had here: http://moi3d.com/forum/index.php?webtag=MOI&msg=6447.31 (the one labeled sinhLeaf) would be like this:

code:
moi.command.execCommand( '_FxGraph3D u;v;((exp(u) - exp((-1)*u))/2 + (exp(v) - exp((-1)*v))/2);-3.14159;3.14159;-3.14159;3.14159;15;15;0;0;0;UV' );

Does that do what you need? If not can you post your .js file and tell me how it's launched so I can better understand what you're trying to do.

- Michael
From: BurrMan
26 Jul 2017   [#43] In reply to [#42]
Well, i dont know if it can be any simpler!!! Lol :)

Just put that command argument in the brackets of the moi.commamd.execCommand()..

(Edit) and end it with a semi colon. (Edit)

Thank you kind sir.
From: Frenchy Pilou (PILOU)
26 Jul 2017   [#44]
Any image of what the formula above do ? :)
From: Michael Gibson
26 Jul 2017   [#45] In reply to [#44]
@Burr - you're welcome!

@Pilou, that particular one makes this:



- Michael

Image Attachments:
pilou_fxgraph.jpg 


From: Frenchy Pilou (PILOU)
26 Jul 2017   [#46] In reply to [#45]
Thx! :)
From: bemfarmer
26 Jul 2017   [#47] In reply to [#42]
Thank you Michael. (I was trying to do some .js with #include _FXGraph3d...)

To implement Michael's code shown in post above, what I did was to create a file called _LeafSinh.js, in notepad++, and copy Michael's code to said file.
Then the _LeafSinh.js file was copied to the MoI3Command folder.
Now the "Leaf" FXGraph3D script can be selected, in MoI, from Ext.Scripts, Max's custom UI.

I think that I recall Burr setting up separate External Scripts files, so I plan to make one for just FXGraph3D scripts (?)
I'll have to look up how to do that...

- Brian
From: BurrMan
26 Jul 2017   [#48] In reply to [#47]
Hi bem,
Well, in these earlier versions of MoI you can just make a folder named "scripts" in the installation root. The command field in MoI reads that folder too.

But things in that folder are for "inline scripts" and they run seperately than commands.

For max's customui, i added a page and directed it to that folder.

I think michael has been discussing that he is looking at changing that seperation.
From: BurrMan
26 Jul 2017   [#49] In reply to [#42]
Worked like a charm! As far as me spelling it out, I left out another part.

"Putting the command. with line parameters into the brackets (), the command is also surrounded by 's. So ('command')

Anyway.....

Show messages:  1-9  10-29  30-49  50-69  70-89  90-91