MoI discussion forum
MoI discussion forum

Full Version: Updates to the MoI API of David C Morrill

Show messages:  1-10  11-30  31-47

From: pressure (PEER)
21 Sep 2022   [#11] In reply to [#7]
Brian,

Where might I find new factories that are undocumented? Near as I can tell they aren't in moi.idl from 2015. Can you think of any off the top of your head?
From: bemfarmer
21 Sep 2022   [#12] In reply to [#11]
Hi Peer,

Flow, Twist,...

The MoI4 commands folder has flow.js, flow.htm, twist.js, flow.htm.

Some are in forum posts, somewhere.
Some are in some scripts that I have done. (?)
Chainmaker.js has Twist and Flow. Maybe check forum posts on chainmaker script

Sorry, I am very busy with work now.
Will do some looking tonight.

- Brian
From: bemfarmer
21 Sep 2022   [#13] In reply to [#9]
The XML looks a lot like a database.

For alternating colors, XSLT:
https://stackoverflow.com/questions/8156906/alternate-row-color-of-table-using-xslt

- Brian
From: Michael Gibson
21 Sep 2022   [#14] In reply to [#13]
Hi Brian,

re:
> The XML looks a lot like a database.

Yeah the way that works is in the XML you can make up your own tag names that contain just plain data content and not any display specific stuff like pixel widths and table structures and such. Then the XSLT part is for generating HTML display content from the XML data.

After setting it up like that then modifying it becomes simpler because you are working with less stuff like you add in something like:

<factory>
   <name>Twist</name>
   <param>
        <description>Text content here</description>
    </param>
</factory>

That XML part is pretty straightforward but the XSLT part is kind of hard to learn.

- Michael
From: pressure (PEER)
21 Sep 2022   [#15] In reply to [#14]
Michael,

Are you up for providing something like an updated moi.idl and a list of all factories? I'm having a hard time sussing out some things related to sceneBrowser, sceneBrowser items, DXF export, SVG export, getDirs, UpdateViewTab, annotation objects, and SaveAs. And I have no clue about what factories have been added aside from what Brian listed.
From: bemfarmer
21 Sep 2022   [#16] In reply to [#11]
I think that NSided and Rebuild have factories, that the API does not document.
Orient, and OrientLineToLine, and ArrayGem, all have factories that are not documented by the API.
Also ExplodeMove, BoundingBox, BoundingBoxCenter, Make2D, and RemoveDuplicates, all have factories that are not documented by the API.

The Inset factory seems to be missing from the API.

I made a printout of MoI Command Reference, and the API factories, and started checking off the ones which seem to have the same factories in common.
But a Command is not a factory, but (often?) uses a factory in its .js code.
I started to get slightly confused. The API does not cross reference factories with commands.
Some Commands have a few types. The API does not show any grouping of related types...
For example, the Offset command includes curve offset, shell, and inset.

- Brian
From: bemfarmer
21 Sep 2022   [#17]
The Moi.idl file is no longer used, as of MoI4:
https://moi3d.com/forum/index.php?webtag=MOI&msg=10518.5

The old, (but latest?) (2015) Moi.idl file is here:
https://moi3d.com/forum/index.php?webtag=MOI&msg=7262.2

- Brian
From: Michael Gibson
21 Sep 2022   [#18] In reply to [#15]
Hi Peer,

re:
> Are you up for providing something like an updated moi.idl and a list of all factories?

Eventually yes but not all right now. Since v4 with the transition to a cross platform code base MoI itself does not use any moi.idl file anymore unlike v3 and earlier. I can help you with specific areas though.

re: sceneBrowser

The base scene browser object is at moi.ui.sceneBrowser, it has read-only properties for

sceneBrowser.objects - root scene browser item for objects section
sceneBrowser.types - root scene browser item for types section
sceneBrowser.styles - root scene browser item for styles section
sceneBrowser.rootItems - list of all root scene browser items


re: sceneBrowser items,

item.name
item.expandable
item.expanded
item.parent
item.children
item.find( 'name' ); - recursive search for child item with given name
item.alterStatus( 'show', true ); - First arg one of 'show', 'hide', 'lock', 'unlock', default if not given is 'show'. Second arg = true for right click behavior.
item.select( 'toggle' ); - // One of 'toggle', 'select', 'deselect', 'filteron', 'filteroff'. Default if not given is 'toggle'.


re: DXF export,

moi.geometryDatabase.fileExport( 'FileName', 'options_string' );

DXF export function parameter options (semi-colon delimited):

NoUI=true
ExportType=2d | 3d
ProjectionView=top | 3d | front | right
WriteCurvesAs=splines | cubicsplines | polylines
PolylineAngleDegrees=10.0
UseSimpleEntities=true
NumDecimalPlaces=12

GenerateHiddenLines=false
HiddenLineLayerMode=fromstyle | custom
HiddenLineLayerName=Hidden lines (layer name to use when layer mode = custom)
HiddenLineLayerPrefixSuffix=prefix | suffix (controls dropdown for which of "prefix" or "suffix" inputs is shown in the UI)
HiddenLineLayerPrefix=prefix_ (prefix to prepend to style name when layer mode = fromstyle)
HiddenLineLayerSuffix=_suffix (suffix to append to style name when layer mode = fromstyle)
IgnoreTangentEdges=false
Resolution=25.0


re: SVG export

PDF/AI/SVG export function parameter options:

NoUI=true
ProjectionView=top | 3d | front | right
ScaleType=fit | preserveunits
MoiScale=1.0
PageScale=1.0
PageUnits=mm | cm | in | pt
CenterOnPage=true

PageSize=letter | legal | tabloid | a3 | a4 | a5 | custom
Landscape=false
PageSizeCustomWidth=8.5
PageSizeCustomHeight=11.0
PageSizeCustomUnits=mm | cm | in | pt

GenerateOutlines=true
GenerateSilhouettes=true
GenerateHiddenLines=false
GenerateCrossHatching=false
ShadedBackground=true
IgnoreTangentEdges=false
Resolution=25.0

Line style properties for visible lines:
VisWidth=0.1
VisColorMode=fromstyle | custom
VisColor=0,0,0 (r,g,b color value for lines when color mode = custom)
VisLayerMode=fromstyle | custom
VisLayerName=Visible lines (layer name to use when layer mode = custom)
VisLayerPrefixSuffix=prefix | suffix (which of prefix or suffix are shown in the UI when layer mode = fromstyle)
VisLayerPrefix= (prefix to prepend to the layer name when layer mode = fromstyle)
VisLayerSuffix= (suffix to append to layer name when layer mode = fromstyle)

Line style properties for outlines:
OutWidth=3.0
OutColorMode=fromstyle | custom
OutColor=0,0,0 (r,g,b color value for lines when color mode = custom)
OutLayerMode=fromstyle | custom
OutLayerName=Outlines (layer name to use when layer mode = custom)
OutLayerPrefixSuffix=prefix | suffix (which of prefix or suffix are shown in the UI when layer mode = fromstyle)
OutLayerPrefix= (prefix to prepend to the layer name when layer mode = fromstyle)
OutLayerSuffix= (suffix to append to layer name when layer mode = fromstyle)

Line style properties for silhouettes:
SilWidth=0.4
SilColorMode=fromstyle | custom
SilColor=0,0,0 (r,g,b color value for lines when color mode = custom)
SilLayerMode=fromstyle | custom
SilLayerName=Silhouettes (layer name to use when layer mode = custom)
SilLayerPrefixSuffix=prefix | suffix (which of prefix or suffix are shown in the UI when layer mode = fromstyle)
SilLayerPrefix= (prefix to prepend to the layer name when layer mode = fromstyle)
SilLayerSuffix= (suffix to append to layer name when layer mode = fromstyle)

Line style properties for hidden lines:
HidWidth=0.1
HidColorMode=fromstyle | custom
HidColor=0,0,0 (r,g,b color value for lines when color mode = custom)
HidLayerMode=fromstyle | custom
HidLayerName=Hidden lines (layer name to use when layer mode = custom)
HidLayerPrefixSuffix=prefix | suffix (which of prefix or suffix are shown in the UI when layer mode = fromstyle)
HidLayerPrefix= (prefix to prepend to the layer name when layer mode = fromstyle)
HidLayerSuffix= (suffix to append to layer name when layer mode = fromstyle)

Line style properties for annotations:
AnnWidth=0.1
AnnColorMode=fromstyle | custom
AnnColor=0,0,0 (r,g,b color value for lines when color mode = custom)
AnnLayerMode=fromstyle | custom
AnnLayerName=Annotations (layer name to use when layer mode = custom)
AnnLayerPrefixSuffix=prefix | suffix (which of prefix or suffix are shown in the UI when layer mode = fromstyle)
AnnLayerPrefix= (prefix to prepend to the layer name when layer mode = fromstyle)
AnnLayerSuffix= (suffix to append to layer name when layer mode = fromstyle)

HiddenLinesOpacity=0.75 (opacity only applies to PDF export, not AI export)
HiddenLinesDashed=true
HiddenLinesDashSize=0.75
HiddenLinesGapSize=1.0

UseAICB=true (for AI copy to clipboard on OSX, for going into Adobe Illustrator CS3 or older).


re: getDirs,

moi.filesystem.getDirs( 'dirname', 'filter*' );

Given a directory name and an optional filter string, return a list of sub-directories within that directory.
For example: var dirs = moi.filesystem.getDirs( 'c:\\', 'p*' );
Filter can be a semi-colon delimited list of filters.


re: UpdateViewTab,

Update view tabs customization
Call a function UpdateViewTab( TabButton ) in the UI when a view tab has been reversed, so that it is possible to implement custom UI like having images there instead of text. Requested on the forum by Tim Whiteman here:
http://moi3d.com/forum/index.php?webtag=MOI&msg=9821.1


re: annotation objects,

annotation.annotationType - one of "LinearDimension", "RadialDimension", "AngularDimension", "Leader", "Text"
annotation.annotationFrame - coordinate frame for the annotation object's plane
annotation.arrowheadType - "arrow", "open arrow", "tick", "dot", "barb"
annotation.arrowLength - pixel arrowhead size when using Scaling: By screen size mode.
annotation.arrowLengthModelUnits - model units arrowhead size when using Scaling: By model units mode.
annotation.arrowWidthFactor - value for aspect ratio to generate width from height
annotation.arrowGap - gap at point of arrow in Scaling by screen size mode
annotation.arrowGapModelUnits - gap at point of arrow in scaling by model units mode
annotation.openArrowLength - length for open arrowhead size in By screen size mode
annotation.openArrowLengthModelUnits - length for open arrowhead in model units mode
annotation.openArrowWidthFactor - same as arrowWidthFactor but for Open arrowheads
annotation.tickLength - size of tick type arrowhead in by screen size mode
annotation.tickLengthModelUnits - size of tick type arrowhead in by model units mode
annotation.tickLineWidth - display line width for tick arrowheads
annotation.reverseTick - reverse tick direction
annotation.dotSize - size of dot arrowhead type in screen size scaling mode
annotation.dotSizeModelUnits - size of dot arrowhead in by model units scaling mode
annotation.extensionLength - length of extension lines in screen size scaling mode
annotation.extensionLengthModelUnits - length of extension lines in model units scaling mode
annotation.extensionGap - gap for extension lines in screen mode
annotation.extensionGapModelUnits - gap for extension lines in model units mode
annotation.arrowLineExtension - arrow line extension in screen mode
annotation.arrowLineExtensionModelUnits - arrow line extensoin in model units mode.
annotation.textAlign - "Left", "Center", "Right", "Justified"
annotation.scaleMode - "By screen size", "By model units"
annotation.height - Text height for By model units mode.
annotation.textBoxPaddingX - left/right text box padding for screen size scaling mode
annotation.textBoxPaddingY - top/bottom text box padding for screen size scaling mode
annotation.textBoxPaddingXModelUnits - left/right text box padding for model units scaling mode
annotation.textBoxPaddingYModelUnits - top/bottom text box padding for model units scaling mode
annotation.textBoxOutline - "None", "Rect", "Bracket"
annotation.textBoxOutlineWidth - width to use for bracket outline in screen size scaling mode
annotation.textBoxOutlineWidthModelUnits - width to use for bracket outline in model units scaling mode
annotation.textMode - "Above", "Inline", "Screen"
annotation.text - text value for annotation, for dims it can contain <> which will be replaced by numeric dimension length
annotation.fontName
annotation.fontPtSize
annotation.fontStyleName
annotation.fontWeight
annotation.fontStyle
annotation.fontUnderline
annotation.fontStrikeout
annotation.distanceDisplay - "Decimal", "Feet & Inches"
annotation.numDecimalPlaces );
annotation.showTrailingZeros
annotation.fractionalDisplayPrecision
annotation.rotateArrowheadPlaneTowardsViewer



re: and SaveAs

moi.geometryDatabase.saveAs( 'FileName', 'OptionsString' );


- Michael
From: pressure (PEER)
22 Sep 2022   [#19] In reply to [#17]
Brian,

Yes I've been going off of the 2015 idl, or rather Tudor's javascript translation of it.
From: pressure (PEER)
22 Sep 2022   [#20] In reply to [#18]
Thanks Michael! What you wrote is even better than what I was hoping for. Thanks for putting it all into human-readable format with comments.

I forgot to ask about trackpadgesture events.
From: Michael Gibson
22 Sep 2022   [#21] In reply to [#20]
Hi Peer,

re:
> I forgot to ask about trackpadgesture events.

Trackpad gesture events are handled internally by the C++ back end, there isn't any scripting involved in that part.

There are some options you can set under Options > View > Rotate/Pan/Zoom options > "MultiTouch options".

- MIchael
From: pressure (PEER)
22 Sep 2022   [#22] In reply to [#16]
Brian,

These are the new factories that I found. Anything missing?

addpointsrf
annotationtext
dimaligned
dimangle
dimhorizontal
dimradius
dimvertical
leader
arraygem
boundingbox
boundingboxcenter
conic
explodemove
flow
group
ungroup
ungroupall
inset
isocurve
make2d
nsided
orient
orientlinetoline
rebuildcurve
removeduplicates
silhouette
twist
viewproject
From: pressure (PEER)
22 Sep 2022   [#23] In reply to [#21]
Michael,

What are the methods for surface area and volume in the Details of the properties panel?
From: Michael Gibson
22 Sep 2022   [#24] In reply to [#23]
Hi Peer,

re:
> What are the methods for surface area and volume in the Details of the properties panel?

They use factories to get the built in non-blocking asynchronous updates.

Factory names: calclength, calcarea, calcvolume. Each takes an object list in input index 0 and fills in index 1 with the result value asynchronously. You have to call factory.waitForAsyncUpdate().

- Michael
From: bemfarmer
22 Sep 2022   [#25] In reply to [#22]
Hi PEER,

It was fairly easy to scan through the MoI5beta commands folder, of the *.js commands, using Microsoft Edge.
(I used to have to copy each file to notepad++)

It looks like you have identified all of the "new" factories, contained in the *.js commands.

However, a couple of points come to mind.

Trim factory has a second possible input for input 6, related to isocurve.
MoI3 has the isocurve factory.
Input 6 of Trim factory, could be more descriptive in your updated API (?)
Maybe API of David C. Morrill was for MoI2?

OrientViewToView.js uses the Orient factory, but the inputs are described a bit differently in the OrientViewToView command, than for Orient command.

Now have a new appreciation of the intricacy of the MoI user interface programming!

The conic factory is used in the Hyperbola and Parabola scripts here:
https://moi3d.com/forum/index.php?webtag=MOI&msg=7777.1772

- Brian
From: pressure (PEER)
23 Sep 2022   [#26] In reply to [#24]
Michael,

Thanks for telling me about these factories. When I search across all text files in the package contents I don't find these. The only place they seem to be mentioned is in moi_lib.dylib. Is that right, or am I missing some .js or .htm in my search?
From: Michael Gibson
23 Sep 2022   [#27] In reply to [#26]
Hi Peer,

re:
> Thanks for telling me about these factories. When I search across all text files in the
> package contents I don't find these. The only place they seem to be mentioned is in
> moi_lib.dylib. Is that right, or am I missing some .js or .htm in my search?

No, they just are being used only by the core C++ code and not being used by scripts.

The internal C++ code can call the same functions that scripts can, and sometimes it's convenient for things that are happening not inside the context of a "command" to be run that way.

For these functions on the object properties dialog, they have to be prepared that it may take some time to number crunch out the result. If they take more than 1 second a "Calculating..." dialog is shown which will let you cancel it. That cancel dialog functionality is set up inside the C++ side with the entry point being moi.ui.propertiesPanel.calcCurveLength() , moi.ui.propertiesPanel.calcSurfaceArea() , or moi.ui.propertiesPanel.calcSolidVolume().

Because you can work with the object properties dialog while you are not running inside a command, the regular command infrastructure was not as suitable for this particular functionality.

- Michael
From: bemfarmer
23 Sep 2022   [#28]
??, Statements which may or may not be correct:
By my limited understanding, a Factory is part of a user interface method, which connects Javascript .js and also .html, to MoI proprietary C++ code.
The associated C++ code is the factory / does the work of the factory.
Javascript code creating the factory, is inputting parameters into the associated factory C++ code.
With the factory, the user can access, or instruct, the work done by the C++ factory, with Javascript .js code. (Within the limitations of the factory instructions/inputs.)
As users, we do not directly mess with the C++ code. It is proprietary, and not permitted by user licensing agreement, which is as it should be.
Programming the C++ code is Michaels prerogative. (I wouldn't have a clue how to do c++ programming anyway :-) )
???
It is nice to be able to do Javascript scripts, to accomplish other tasks.

There is other user interface code which is not a factory. (?)
There is other, non-factory, interface code, which could be useful when creating scripts.(?)

I guess that API documentation, or Scripting documentation, is/ could be/ should be, more than just Factory documentation?

- Brian
From: Michael Gibson
23 Sep 2022   [#29] In reply to [#28]
Hi Brian,

re:
> I guess that API documentation, or Scripting documentation, is more than just Factories?

Yes, that's true.

Geometry factories are just one part of the whole system, like you wrote above a geometry factory is something set up to assist making commands. They are set up so that you can basically connect a UI control with a factory input ("binding") and then when the UI control is modified the factory will update and recalculate the result and deal with a bunch of things like deleting any previous results and restoring the original objects if the command is canceled and stuff like that.

That's quite a bit of stuff that many command scripts would need to do so it's helpful if that can be packaged up so that each command script doesn't have to those things themselves.

- Michael
From: pressure (PEER)
23 Sep 2022   [#30] In reply to [#27]
Michael,

So, should I include these factories, or will trying to use them in a custom javascript command cause problems?

arrow3d
backgroundimagerotatewheel
baserectangle
calcarea
calclength
calcvolume
drag
dragpointoncurve
labelpoint
objectframerotate
objectframerotatewheel
objectframescale
pdfencoding
scalenonuniform

Show messages:  1-10  11-30  31-47