MoI discussion forum
MoI discussion forum

Full Version: Script to create leaders with coordinates

From: Larry Fahnoe (FAHNOE)
29 Oct 2020   [#1]
Building upon MoI’s new Leader tool, Coordinates is a script that creates leaders with either 2D or 3D coordinates depending on the view chosen. My intent was to be able to add feature coordinates to construction drawings, for example the coordinates of the holes of a bolt circle, though I suspect it will have other uses. The script allows adjusting the origin and axes by establishing a CPlane; for example the model part can be made to correspond to how the actual part will be referenced on a given machine. Display precision is controlled by Options > Dimensions > Formatting: Decimal display. Because the script can create multiple leaders, while the command is running Cancel or Undo removes leaders one at a time rather than removing everything just created. Leaders for the 2D views can optionally be prefixed with axis labels.

The script requires MoI v4 or the final v4 beta; it does not work properly with the earlier betas.

This effort is based upon the excellent examples found in MoI’s commands along with insights gleaned from the forum, thanks!

The first two examples use a property preset named Coordinates with Outline: Rect, Arrowhead: Dot, and Dot size: 2. The property preset is created in Options > Dimensions. With a little editing of the resulting leaders, the third example gives another idea of a use for the script.

--Larry










Attachments:
Coordinates-009.zip

Image Attachments:
Coordinates-example-1.png  Coordinates-example-2.png  Coordinates-example-3.png  Coordinates-palette.png 


From: Frenchy Pilou (PILOU)
29 Oct 2020   [#2] In reply to [#1]
Seems very cool...have you a little animation of that ?
From: Mik (MIKULAS)
29 Oct 2020   [#3] In reply to [#1]
Very cool script!
Thanks for sharing.
Mik
From: Larry Fahnoe (FAHNOE)
29 Oct 2020   [#4] In reply to [#2]
Hi Pilou,

No, I'm sorry I do not. I have certainly been impressed with your animated examples, a very good way of explaining things.

--Larry
From: Frenchy Pilou (PILOU)
29 Oct 2020   [#5] In reply to [#4]
As soon as free times i will Download your plugin (if yet working (?) ) and will make a little anim :)
From: BurrMan
29 Oct 2020   [#6] In reply to [#1]
Hi Larry,
Nice work!

Just a nbote: The html file in your download is missing tyhe text for the 3rd tick box labeled "Project to cplane"...

I added it to mine. Maybe you want to fix the initial file for download....

Thanks for sharing your work.
From: Larry Fahnoe (FAHNOE)
29 Oct 2020   [#7] In reply to [#6]
Hi BurrMan,

Thanks!

The missing text is odd as the button is essentially (shamelessly) copied from Leader.htm. I would think that the source of the text would be MoI's language support, what language is your MoI using? Mine is set to English and the palette looks like what I show above. I just ran through all the languages and each one is showing the text "Project to cplane" next to the last check box. I presume that means Michael doesn't have this particular string translated to the other languages yet. I wonder what other people are seeing.

code:
 <moi:CheckButton id="ProjectToCPlane" default="false"><moi:Text textid="Dim project to cplane checkbox"/></moi:CheckButton>


To add: the <Moi:Text textid="..."> should pull the translated string from MoI's language support. Was your's showing nothing after the checkbox?

--Larry
From: BurrMan
29 Oct 2020   [#8] In reply to [#7]
Hi Larry,
My language is English. Nothing fancy.

The tickbox is there, there is just no text.

I opened the html file and added it to the line of code you show there. (Your line has the text empty also)

Your other tick marks have the text written in that spot of the code....
From: Larry Fahnoe (FAHNOE)
29 Oct 2020   [#9] In reply to [#8]
Hi BurrMan,

Where possible I am making use of the internationalized strings already present in MoI. In the case of the "Project to cplane" CheckButton, the text is already provided by MoI and in use by the dimension/annotation commands so adding it to the CheckButton in this script should be redundant. The other two CheckButtons are unique to my script and thus I provided the text for them. Obviously it didn't work properly & I'm perplexed as to why it works for me but not for you. I'm running a fairly vanilla MoI v4 Oct 27 beta. My only UI tweak is Michael's SeparateSidePanePalettes.js which I've now removed and note that the "Project to cplane" text is still displayed.

Do you see the "Project to cplane" text after the check boxes in the other MoI dimension/annotation commands?

Do you use CustomUI or other startup scripts?

The only difference between the CheckButton's use in Leader vs. my script is that I omitted the style="persist:false" (which I didn't understand) and added default="false" which may be unnecessary:
code:
Leader.htm:
<moi:CheckButton id="ProjectToCPlane" style="persist:false"><moi:Text textid="Dim project to cplane checkbox"/></moi:CheckButton>

Coordinates.htm:
<moi:CheckButton id="ProjectToCPlane" default="false"><moi:Text textid="Dim project to cplane checkbox"/></moi:CheckButton>

--Larry
From: BurrMan
29 Oct 2020   [#10] In reply to [#9]
Hi Larry,
I see. Well, i dont understand much about moi's ui that way, so i would be a bad choice to help track something down, or confirm it that way....

So far, nobody else is having any issue with it. So if it's "just me", then there is no real need to lose hair....

If it turns out to affect others, maybe Michael will jump in to help...
From: BurrMan
29 Oct 2020   [#11] In reply to [#9]
BTW: my guess would be it's a read/write issue on my end.

I run my MoI self contained, so my commands arent in my appdata folder...

I can do a test tommorow to see if the text "gets" if i run MoI as admin....
From: BurrMan
29 Oct 2020   [#12] In reply to [#11]
So I just tested. My guess was wrong...

But this:

""""""""""""Do you see the "Project to cplane" text after the check boxes in the other MoI dimension/annotation commands?""""""""""""""""

No. I cant find anything related to cplane projection in any of the dimension commands...

Mine just automatically projects to the current cplane... But I have no checkboxes for it...

Can someone else show me a screenshot of these checkboxes in the normal dimension commands?

Maybe Michael can clarify.
From: bemfarmer
29 Oct 2020   [#13] In reply to [#12]
The coordinates script menu text "Project to cplane" does NOT appear in the Sept 10 2020 beta,
but DOES appear in the October 27 2020 beta. (Ditto for the dim dimensions menu's, for old beta.)
( A guess is that Apparently the text does not exist at all in the old beta.)

Larry's coordinates.js and .htm files can be copied to either %APPDATA% commands folder, or C:\program files\...Latest MoI Oct 2020 beta commands folder,
(Or Both folders, if one has the underline prefix for the .js and .htm file.) Accessable with customUI, (or I suppose by tab command entry box in MoI.)

(Not sure about BurrMan's "portable" setup...)

- Brian
(Windows 10)

Larry, a very cool script!

Message 10013.14 was deleted


From: Michael Gibson
29 Oct 2020   [#15] In reply to [#12]
Hi Burr, yes that text is new in the just released Oct-27-2020 v4 beta. If you don't see it that probably means you're running the Sep-10 v4 beta instead of the new one:

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

- Michael
From: Larry Fahnoe (FAHNOE)
30 Oct 2020   [#16]
Thanks Brian and Michael, I should have begun by asking what version BurrMan was running, but of course I made the problem more complicated than need be... ;-}

Planning for life beyond the v4 beta cycle, the code does check moi.majorVersionNumber, but that doesn't help to warn about a particular beta version.

Hopefully once BurrMan gets the Oct 27 beta all will be well!

--Larry
From: BurrMan
30 Oct 2020   [#17] In reply to [#16]
Well, Crap.....

Please disregard my posts on that.. sorry.
From: Larry Fahnoe (FAHNOE)
30 Oct 2020   [#18] In reply to [#17]
No worries! The new features in the Oct 27 beta are a real treat & will also make my script function as intended.

--Larry