Hexagon Geospatial
MENU

Developer Discussions

Discuss topics with other Hexagon Geospatial Power Portfolio developers and experts to get the most out of our products.
Showing results for 
Search instead for 
Do you mean 
Reply
Highlighted
Frequent Contributor
Posts: 137
Registered: ‎01-14-2018
Accepted Solution

Automating Copy of styles from a library to gws

[ Edited ]

Dear all,

 

I need to copy a style subfolder called "New Folder" from a library connection to a gws, 

I already made the connection to the library using the below code:

 

PLSS.LibraryConnection libraryConnection =this._currentApplication.CreateService("GeoMedia.LibraryConnection") as PLSS.LibraryConnection;
libraryConnection.Name = "Access Library Connection 1";
libraryConnection.Description = "Library";
libraryConnection.Mode = 1;
libraryConnection.ConnectionString = @"TYPE=GDO;PROGID=ACCESS.GDatabase;LOCATION=C:\Users\A\Desktop\Edited\try\LibTemp.mdb";

libraryConnection.Connect(true, null);
        
PLSS.LibraryConnections libConns = this._document.LibraryConnections as PLSS.LibraryConnections;
libConns.Append(libraryConnection);    

 

And I copied the content of the library as follows:

 

PLSS.Library objLibrary = libraryConnection.Library;

PLSS.LibraryStorageService libStorSrvc = this._currentApplication.CreateService("GeoMedia.LibraryStorageService") as PLSS.LibraryStorageService;
libStorSrvc.LibraryConnection = libraryConnection;
libStorSrvc.CopyMode = 1;
libStorSrvc.TargetConnections = this._document.Connections;
libStorSrvc.TargetCoordSystemsMgr = this._document.CoordSystemsMgr;
libStorSrvc.TargetQueryFolder = this._document.QueryFolder;

PLSS.LibraryFolder libfold = objLibrary.StyleFolder;
PLSS.LibraryFolder libfoldinner = libfold.LibrarySubFolders[1]; //New Folder

object objCreatedCopy = libStorSrvc.CopyFromLibrary(libfoldinner.LibrarySubFolders[1].Moniker, true);

PView.StyleFolder docStyleFolder = this._document.StyleFolder as PView.StyleFolder;
PView.StyleFolder docStyleFolderinner = objCreatedCopy as PView.StyleFolder;
docStyleFolder.StyleSubFolders.Append(docStyleFolderinner);

 

 

 

This Post is edited as I found a way to do it and the above code now works,

 

Khaled

Frequent Contributor
Posts: 137
Registered: ‎01-14-2018

Re: Automating Copy of styles from a library to gws

I finally got it right:

 

The Style folder is saved as a library folder under the Library, so I firstly made a library folder "libfold" respresenting the library style folder.

 

In order to control my style subfolder named "New Folder" under the library stylefolder I had to make another library folder "libfoldinner" representing the LibrarySubFolders[1] which in my case respresent the "New Folder" style subfolder.

 

Then I created a copy of this "New Folder" using "CopyFromLibrary" method.

 

In order to receive that copy in the gws style folder I made the following:

Created a stylefolder "docStyleFolder" representing the document stylefolder,

Created another stylefolder called "docStyleFolderinner" and I set it to the object returned from the "CopyFromLibrary" method.

Then I appended the "docStyleFolderinner" as a stylesubfolder into the "docStyleFolder"

 

I edited the code above.

 

I hope this answer could benefit you.

Khaled

Polls
Please register to vote
Do you need immediate support?
Please submit a Ticket through our
Development Ticket Portal.