ArcCAM
 1-18  19-38  39-58  59-78  79-81

Previous
Next
 From:  Michael Gibson
11543.59 In reply to 11543.58 
Hi Len, both getOption and setOption need to have the "use ini" parameter added.

If you call moi.command.getOption( 'ArcCAM.htm_test' ) that will get it from the runtime storage.

You need to call moi.command.getOption( 'ArcCAM.htm_test', true ) to get it from ini storage.

You don't want to have a mismatch with the get coming from runtime storage and the set going to ini storage.

It's good to have the get wrapped in a try / catch block to handle the exception that will be triggered if there isn't any value present.

var value = false;

try {
    value = moi.command.getOption( 'ArcCAM.htm_test', true );
} catch(e) {}

It would probably have been better for this to return undefined if no value had ever been set rather than throwing an exception but it's difficult to change things that are in use.

- 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:  probotix
11543.60 In reply to 11543.59 
I was watching the ini file to see if it changed and it did not. Is the ini file only written on close?

>Len
  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:  probotix
11543.61 In reply to 11543.60 
Is there a way to run a command from a directory other than moi://AppData/commands? I have tried a few different ways, but nothing seems to work.

code:
<moi:CommandButton icon="moi://appdata/icons/ArcCAMIcon.png" command="moi://appdata/ArcCAM/ArcCAM.js">


>Len
  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
11543.62 In reply to 11543.60 
Hi Len,

re:
> I was watching the ini file to see if it changed and it did not. Is the ini file only written on close?

Yes, the moi.ini file is read from disk when the program starts, and written to disk when the program ends.

Any changes to it during run time happen to an in-memory version.

You can trigger it to be written by calling moi.settings.writeIniFile();

- 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
11543.63 In reply to 11543.61 
Hi Len,

re:
> Is there a way to run a command from a directory other than moi://AppData/commands? I
> have tried a few different ways, but nothing seems to work.

It will look first in the install commands directory, then in the appdata commands directory and then through any directories listed in moi.ini under
[Commands]
AdditionalCommandsDirs=

There can be multiple directories listed there separated by semi-colons.

- 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:  probotix
11543.64 In reply to 11543.63 
Michael,

Can I use moi://appdata/ or %appdata% as part of the path to AdditionalCommandsDirs?

>Len
  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:  pressure (PEER)
11543.65 In reply to 11543.64 
Hi Len,

Re:
> Can I use moi://appdata/ or %appdata% as part of the path to AdditionalCommandsDirs?

Have you looked at the example function called instantScript() in the API? I'm wondering if maybe running your code as a script rather than a command might give you more flexibility. Another thing to look at is shellExecute in the Filesystem section.

- Peer
  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:  probotix
11543.66 In reply to 11543.65 
I'll look into instantScript() closer. I have already tested shellExecute and may use that for some python or database connectivity. But it still doesn't solve the ease of installation issue.

Its easier to tell someone to put this exactly in your ini file:

"moi://appdata/ArcCam"

Than to tell them:

"C:\users\YOUR WINDOWS USERNAME HERE\AppData\Roaming\Moi"

A lot of them wouldn't even know what their Windows username is. Windows is frustrating compared to how easy I can do this stuff in Linux.

>Len
  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:  pressure (PEER)
11543.67 In reply to 11543.66 
Hi Len,

For seamless installation I guess you'd need a standalone installer script that asks MoI for the location of the appData directory, copies your files there, and maybe writes the path to moi.ini if the files are put in their own folder. I can't think of a way to add a command just by typing something in moi.ini

The closest thing I've done is a startup script that replaces a native file with my own by copying my html file from the startup scripts folder. That still requires manually navigating to the startup scripts folder to put the script and html there though.

code:
doReplacePromptSaveChanges();

function doReplacePromptSaveChanges() {

    var existingName = moi.filesystem.getUiDir() + 'PromptSaveChanges.htm';
    var backupName = existingName + '.bak';
    var backupExists = moi.filesystem.fileExists( backupName );

    if (backupExists === false) {

        // backup PromptSaveChanges.htm
        moi.filesystem.copyFile(existingName, backupName );

        // overwrite PromptSaveChanges.htm
        var replacerName = moi.filesystem.getAppDataDir() + 'startup/' + 'PromptSaveChanges.htm';
        moi.filesystem.copyFile(replacerName, existingName );
    }
}


- Peer
  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
11543.68 In reply to 11543.64 
Hi Len,

re:
> Can I use moi://appdata/ or %appdata% as part of the path to AdditionalCommandsDirs?

Unfortunately no, it can only take a regular file system path there, not a moi:// URL or environment variable.

How about a new mechanism that would scan through any folders under say appdata/plugins and look for a commands folder inside of there.

So then the install would be to put your stuff inside appdata/plugins/ArcCAM and your commands would be under appdata/plugins/ArcCAM/commands and I could also look for startup scripts inside appdata/plugins/ArcCAM/startup ?

And you could put images inside appdata/plugins/ArcCAM/icons and those would work already using moi://appdata/plugins/ArcCAM/icons/file.png .

- 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:  probotix
11543.69 In reply to 11543.68 
Michael,

I like it!

I've been messing around with NSIS today, and it is able to fiddle with moi.ini, but I don't feel comfortable with that. Having a plug-in container seems much safer.

>Len

EDITED: 14 Oct 2024 by PROBOTIX

  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
11543.70 In reply to 11543.69 
Hi Len, ok I will set this up for the next v5 beta. So it will look for commands in directories inside appdata/plugins/<PluginName>/commands and will also look for startup scripts (scripts to run when MOI is launched) under appdata/plugins/<PluginName>/startup.

So you won't have to modify moi.ini for that and to install you can have it in a .zip and unzip it under appdata/plugins.

- 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:  pressure (PEER)
11543.71 In reply to 11543.70 
Hi Michael,

Will it also look for appdata/plugins/<PluginName>/scripts ?

- Peer
  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
11543.72 In reply to 11543.71 
Hi Peer,

re:
> Will it also look for appdata/plugins/<PluginName>/scripts ?

I should be able to make that work too.

- 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:  pressure (PEER)
11543.73 In reply to 11543.72 
Thanks Michael. I like this new plugin folder idea of yours.

- Peer
  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:  probotix
11543.74 In reply to 11543.72 
Michael,

I have added a plasma table module to ArcCAM. Any idea when you're gonna release the next beta?

>Len
  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
11543.75 In reply to 11543.74 
Hi Len,

re:
> Any idea when you're gonna release the next beta?

Probably within the next couple of weeks.

- 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:  probotix
11543.76 In reply to 11543.75 
For my plasma script, I want to be able to set the cplane to a surface and translate curve coordinates to x,y values relative to the cplane. Before I write a function that takes the vectors from moi.view.getCPlane() and translates x,y,z values to values relative to the cplane origin, is there a better way to do what I am wanting?

[object MoiCoordinateFrame]
origin=0.9706,2.7112,2.7112
xaxis=1,0,0
yaxis=0,0.7071,0.7071
zaxis=0,-0.7071,0.7071



Also, is there an easy way to select the curve that makes up the surface?

>Len
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
11543.77 In reply to 11543.76 
Hi Len,

If you have a coordinate frame and you want to translate a point from world coordinates into that local frame's coordinates you can do this:

var local_x = frame.distancex( global_pt );
var local_y = frame.distancey( global_pt );
var local_z = frame.distancez( global_pt );


> Also, is there an easy way to select the curve that makes up the surface?

I'm sorry I'm not understanding this part. What is the curve that makes up the surface? A curve used to generate the surface with a particular command? The edges of the surface?

- 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:  probotix
11543.78 In reply to 11543.77 
Yes, the edges of the surface?

Lets just say a cube to keep it simple. Select a face, and then have the script return the curve object which is a square made up of four line segments.

>Len
  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-18  19-38  39-58  59-78  79-81