I have studied pages on userdata:
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!!
Here is a sample that you might find worth reviewing:
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?
>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.
Subscribing to new document and begin open document events worked..
Thank you very much!!!