Nevron Forum

Trying to Create shape instance of master from custom library

https://www.nevron.com/Forum/Topic3606.aspx

By Jason Irby - Friday, May 28, 2010

 

I guess this should be easy but i'm not getting it, and I haven't found anything in the examples that makes it clear.

 

I have a custom library that I have persisted out to file.

I have loaded this file into a NLibraryDocument thru the PersistencyManger.

I now want to create an NShape instance of one of the Masters within the LibraryDocument, and insert it into my drawing programatically.

I was looking for some kind of shape factory that could take my LibraryDocument and expose instantiation methods for the contained masters, but I haven't found anything like that.

How should I approach this.

Thanks in advance.

Regards,

Jason Irby

 

 

 

 

By Nevron Support - Monday, May 31, 2010

Hi Jason,

Use the CreateInstance method of the master, which takes a drawing document and a center point. The method creates an instance of the master content in the active layer of the specified drawing document, and centers it at the specified point. For example:

master.CreateInstance(drawingDocument, new NPointF(100, 100));

In general a master is slightly more complex than a shape factory. The complexity arises from the fact that a shape factory creates only single shapes, while a master can contain multiple shapes and the connections between them. This means that not only single shapes, but entire drawing fragments (clippings) can be stored in masters for reuse in multiple drawings.