Script: obtain parameters from other commands/script

Next
 From:  miquik
10900.1 
Hi all,
I'm writing a new script and I would need to obtain "line settings" parameters from "AI exporter" script. How can I do that?
I know I could read these settings from moi INI file, but 1) I have to parse entire INI file to found my parameters and mainly 2) if I change setting in "AI exporter" modal then I have to restart MOI to have corrected values.

Thank You,
Michele
  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
10900.2 In reply to 10900.1 
Hi Michele, a script can set options for AI export by passing in values in the options string which is the 2nd parameter to moi.geometryDatabase.fileExport() and moi.geometryDatabase.saveAs().

But there is not currently any method set up for a script to read those values instead of setting them.

Could you maybe describe a little more about what you're trying to do?

- 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:  miquik
10900.3 In reply to 10900.2 
Hi Michael,
My script generate an AI file from geometry then read it to perform some operations. To do so, I need to know what layer name/color/width user has choosen from AI exporter.
I can read these informations from AI file, but I need to process layers in specific order and then I have to be sure AI exporter will always export data in same order.

An additional question: in my script user can set some custom properties; how can I "persist" those values so when I open MOI again I have those properties filled with default values?
Should I write to INI settings file? Can I do that?

Thanks
  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
10900.4 In reply to 10900.3 
Hi Michele, for the next v5 beta I've added in a function that will flush the moi.ini file settings that are in memory out to disk as normally happens when you exit from MoI. I'll also add a function for retrieving a value from the in memory moi.ini settings.

re:
> Should I write to INI settings file? Can I do that?

Yes, a script can persist a value to moi.ini by using:

moi.command.setOption( OptionName, OptionValue, true /*To ini*/ );

It can read it back using:

var val = moi.command.getOption( OptionName, true /*From ini*/ );

If there is no value previously st then moi.command.getOption() will throw an exception so you need to put it in a try/catch block something like this:

var value = 0;
try { value = moi.command.getOption( 'optionname', true ); }
catch(e) { }

Options saved using this method will be stored in the [Commands] section of the moi.ini file.

- 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:  miquik
10900.5 In reply to 10900.4 
Thanks Michael,
I realize I can explain you exactly what I'm trying to achieve, maybe (if you think it's a usefull feature) you can easily integrate into MOI.
I need to export 3D geometry to DXF, but current exporter only allow to generate visible/hidden lines.
AI/PDF exporter can manage silhouettes/outlines choosing colors/layer names/line widths.
So AI exporter is good but it generates a lot of duplicate lines.
One last thing, every exporter generates all lines, I would need to "simplify" somehow visual appareance of DXF result.

So I create the attached script. It's not complete but it *should* work. Is very simple but the tests are encouraging

I would like to know if it will be possible to integrate into engine, I think will be useful for "technical illustration"
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
10900.6 In reply to 10900.5 
Hi Michelle, yes DXF export only generates visible/hidden lines and not things like silhouettes and outline curves.

PDF/AI/SVG output generates those things to make a type of 2D illustration style output which is usually done with 2D vector drawing programs and not usually with 2D CAD programs which is what DXF format is more associated with.

- 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:  pressure (PEER)
10900.7 In reply to 10900.5 
Hi Michele,

Are you maybe trying to do something like prepare artwork for CAM like for a laser engraver, vinyl plotter, or CNC router? Do you want to engrave/route/plot a line drawing of a 3D model?

You probably already know all of this, but just in case: There's a plugin for Illustrator that's good for removing short lines and there's a macro for CorelDraw http://makerspacemobile.org/wiki/index.php/GCC_Venus for removing duplicate lines, though I don't have experience with that macro.

Have you considered saving the AI / SVG / PDF output as a high resolution bitmap and then vectorizing (tracing) the bitmap in Corel or Illustrator?

Nice script by the way! Looks quite advanced :)

- 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
 

Reply to All Reply to All