Hello, 

I have studied pages on userdata:

http://wiki.mcneel.com/developer/userdata

http://wiki.mcneel.com/developer/sdksamples/documentdata

I was able to read/write the plugin data in document data.. 

Problem: I want to figure out when user changed the document or precisely differentiate between these two use cases:

1. User opened a document which has plugin data ---- Plugin read the data from .3dm file. 

2. User opened a document which has plugin data ---- Plugin read the data from .3dm file---- User opened a document which does not have plugin data----(Since data was already read when user opened first document, plugin assumes that even the new document has this plugin data. )

So is there a way for plugin to know when the user opened a document or created a new document?

If not, is there a way to read the document data anywhere other than

public override bool ReadDocument(MRhinoDoc doc, RMA.OpenNURBS.OnBinaryArchive archive, IRhinoFileReadOptions options)

If not, do you think I need to write plugin data as object user data(instead of document data) and attach it to some entity in rhino?

Thank you for your help!!

Regards

Varun

Views: 271

Replies to This Discussion

Hi Varun,

Here is a sample that you might find worth reviewing:

https://github.com/dalefugier/SampleCsDocumentUserData

Your plug-in's ReadDocument() member is called when Rhino discovered that the document it was reading contains your user data. Rhino passes ReadDocument() a FileReadOptions object that contain in what context the reading is occuring: new document, open document, import document, etc.

Does this help?

 -- Dale

Hello Dale,

New document does not have any plugin data.. So will rhino call plugin's ReadDocument when a new document is created?
Is there any way for plugin to know that a new document event is triggered in rhino?

If the user has opened a document that has plugin data, plugin reads it, but after this if user creates a new document, plugin's read document wont be called.. and so plugin will not know that this is a new document and it does not have any plugin related data.

I studied the sample shared by you.. Even in this sample, the plugin does not get a call in ReadDocument when user is creating a new document.

Regards
Varun

>New document does not have any plugin data.

ReadDocument() is only called when Rhino is reading a document, either an existing document or a new document based on an existing template, that contains your plug-ins document data.

>If the user has opened a document that...

If you want to know when a new document is being created, then subscribe to the Rhino.RhinoDoc.NewDocument event. I've updated the sample to show you how to do this.

https://github.com/dalefugier/SampleCsDocumentUserData

 -- Dale

Hello Dale, 

Subscribing to new document and begin open document events worked.. 

Thank you very much!!!

Regards

Varun

RSS

Translate

© 2014   Created by McNeel Admin.

Badges  |  Report an Issue  |  Terms of Service