V5 Notes Feature - two scripts and 1st Step to Automation?

Next
 From:  stefano (LIGHTWAVE)
11509.1 
Hi Michael,

Could not seem to attach a file to previous thread about notes.
So created this new one.

Could I request two basic scripts that i think would be useful to many users.
These are for the global notes area, so global or 'document related' not object related.

1. NOTES-CLIP
Copies file/notes to clipboard.

2. NOTES-CLIP-DIM
Copies file/notes to the clipboard and
creates a dim/text object.
creates object name: "Notes"
Result shown on the .3DM

--------------

EDITED: 11 Aug 2024 by LIGHTWAVE


  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
11509.2 In reply to 11509.1 
Hi stefano,

re:
> 1. NOTES-CLIP
> Copies file/notes to clipboard.

Try this:
script: moi.copyTextToClipboard( moi.geometryDatabase.notes );


> 2. NOTES-CLIP-DIM
> Copies file/notes to the clipboard and
> creates a dim/text object.
> creates object name: "Notes"
> Result shown on the .3DM

The dim/text object needs an anchor point, where do you want it placed at?

- 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:  stefano (LIGHTWAVE)
11509.3 In reply to 11509.2 

Hi Michael thanks for this.

Re anchor point..

Been doing a lot of tests with your pdf export
and external software. The anchor point for the
notes text id likely place on LHS of the viewport and we’d try to make it positioned LHS of an A4 pdf, I’d likely have to move it depending on what’s selected and show it once when creating visual output.

Fundamentally It’s something I’d likely print once to pdf so feel the ideal functionality is lto also hide it on 1st activation…

  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
11509.4 In reply to 11509.3 
Hi stefano, I would need an x,y,z coordinate location for the text anchor point to be able to do the 2nd script.

- 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:  stefano (LIGHTWAVE)
11509.5 In reply to 11509.4 
Hi Michael,
Let's keep it simple, 0,0,0 will be fine.
Please could i request the dim-text block "object" (named NOTES)
it is hidden on activation? BR Stefano
  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
11509.6 In reply to 11509.1 
Hi Stefano,

re:
> 2. NOTES-CLIP-DIM
> Copies file/notes to the clipboard and
> creates a dim/text object.
> creates object name: "Notes"
> Result shown on the .3DM

Here is a script that will do this sequence. The text object that is created is hidden.

script: moi.copyTextToClipboard( moi.geometryDatabase.notes ); var factory = moi.command.createFactory( 'annotationtext' ); factory.setInput( 0, moi.vectorMath.createTopFrame() ); factory.setInput( 1, moi.geometryDatabase.notes ); factory.setInput( 2, 0 ); factory.update(); var objs = factory.getCreatedObjects(); objs.setProperty( 'hidden', true ); objs.setProperty( 'name', 'Notes' ); factory.commit();

- 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:  stefano (LIGHTWAVE)
11509.7 In reply to 11509.6 
Hi Michael thanks for this I’m reading the script and some seems understandable and some not so much…

just wondering / curious what part is relating to xyz position or where the text object is positioned…
  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
11509.8 In reply to 11509.7 
Hi stefano, yeah it can be hard to read ones that have been condensed to one line for shortcut key pasting.

Here it's separated out:

moi.copyTextToClipboard( moi.geometryDatabase.notes );

var factory = moi.command.createFactory( 'annotationtext' );
factory.setInput( 0, moi.vectorMath.createTopFrame() ); <<<<<<<<<<<<<<<<
factory.setInput( 1, moi.geometryDatabase.notes );
factory.setInput( 2, 0 ); factory.update(); // Index of annotation property preset to use, 0 = "Default" preset values used.

var objs = factory.getCreatedObjects();
objs.setProperty( 'hidden', true );
objs.setProperty( 'name', 'Notes' );
factory.commit();


The line marked with <<<<<< is the one that sets the position.
moi.vectorMath.createTopFrame() will generate a coordinate frame object (made up of an origin point, and vectors for x,y,z axis directions) with world aligned x,y,z axes and origin at 0,0,0 by default.

If you wanted it to go at x=10, y=5 you could do it like this:
var frame = moi.vectorMath.createTopFrame();
frame.origin.x = 10;
frame.origin.y = 5;
factory.setInput( 0, frame );

- 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:  stefano (LIGHTWAVE)
11509.9 In reply to 11509.8 

Hi Michael the code looks very compact / efficient
So I think when you say

moi.vectorMath.createTopFrame() );

That means xyz = 0 and that expression = default position.

But if I wanted it to be less efficient with the code or longhand and see where to change xyz the values by code, I guess it is:

var frame = moi.vectorMath.createTopFrame();
frame.origin.x = 0;
frame.origin.y = 0;
factory.setInput( 0, frame );.

[where’s the z though ? is it in the empty () after Top Frame or is it in the set input ( 0, frame );

or can we have -

var frame = moi.vectorMath.createTopFrame();
frame.origin.x = 0;
frame.origin.y = 0;
frame.origin.z = 0;
factory.setInput( 0, frame );.

  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
11509.10 In reply to 11509.9 
Hi stefano, yes that last one should work:

var frame = moi.vectorMath.createTopFrame();
frame.origin.x = 0;
frame.origin.y = 0;
frame.origin.z = 0;
factory.setInput( 0, frame );

- 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:  stefano (LIGHTWAVE)
11509.11 In reply to 11509.10 
Thanks again Michael. I’ve just moved my level of coding upwards from zx81, y0; Moi.factory.setitlikeapun);


  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