Get worksets from detached model

Get worksets from detached model

Kisli89
Enthusiast Enthusiast
1,083 Views
2 Replies
Message 1 of 3

Get worksets from detached model

Kisli89
Enthusiast
Enthusiast

Hello, I need to get all the Workset in the model. I usually use something like this -

List<WorksetPreview> Worksets = WorksharingUtils.GetUserWorksetInfo( ).ToList();

But if the central model is not (removed), then it does not work and you have to use this code -

var wsrevs=new List<WorksetPreview>();
var tb = doc.GetWorksetTable();
try {
   for (int i = 0; i < 999999; i++) {
      Workset wset = tb.GetWorkset(new WorksetId(i));
      wsrevs.Add(wset);
   }
}
catch {

}

It seems to me not very right, maybe there is another way?

0 Likes
Accepted solutions (1)
1,084 Views
2 Replies
Replies (2)
Message 2 of 3

RPTHOMAS108
Mentor
Mentor
Accepted solution
 Dim WF As New WorksetKindFilter(WorksetKind.UserWorkset)
 Dim FWC As New FilteredWorksetCollector(Document)

 FWC.WherePasses(WF).ToWorksets()
 'or
 FWC.WherePasses(WF).ToWorksetIds()

Perhaps these objects above?

 

Note that when you detach a model there is an option for discarding worksets. A detached model only really exists between the time you detach and when you first save it.

Message 3 of 3

Kisli89
Enthusiast
Enthusiast

Thanks!


@RPTHOMAS108 wrote:
 Dim WF As New WorksetKindFilter(WorksetKind.UserWorkset)
 Dim FWC As New FilteredWorksetCollector(Document)

 FWC.WherePasses(WF).ToWorksets()
 'or
 FWC.WherePasses(WF).ToWorksetIds()

Perhaps these objects above?

 

Note that when you detach a model there is an option for discarding worksets. A detached model only really exists between the time you detach and when you first save it.


 

0 Likes