1、Revit 工作集协同模式的工作集协同模式的APIAutodesk中国研究院 开发经理首届中国开发者训练营首届中国开发者训练营DevCamp China 1st 刘培珺职务/Autodesk中国研究院 开发经理部门/IPG 2004年毕业于浙江大学CAD&CG国家重点实验室并获得工学博士学位。毕业后加入阿尔卡特从事无线研发工作。2006年加入Autodesk AEC部门,Revit API 团队开发经理,负责Revit API的设计、开发与测试。 认识我认识我 对于大型的设计项目,有效地协同工作、工作共享可以提高建筑设计的效率,优化建筑的经济性,对于设计团队来说无疑是非常重要的话题。本课程将从
2、二次开发的角度,介绍工作共享相关API的设计与使用。课程简介课程简介 Revit工作共享主要工作流程 工作共享中的数据操作 工作共享中的工作集管理 工作共享中的权限管理 工作共享的显示模式 工作共享相关的事件日程日程什么是工作共享?什么是工作共享?Revit工作协同功能工作协同功能工作协同主要工作协同主要流程流程8创建中心文件创建中心文件保存打开工作共享创建本地文件创建本地文件打开保存数据保存数据保存保存权限同步到中心文件数据提取数据提取载入最新工作集保存数据修改数据修改修改权限授权没有权限授权Worksharing API Save, SaveAs, SaveOptions和Workshar
3、ingSaveAsOptions Open和OpenOptions ReloadLatest,HasAllChangesFromCentral和ReloadLatestOptions SynchronizeWithCentral,SynchronizeWithCentralOptions,RelinquishOptions和TransactWithCentralOptions工作共享数据操作工作共享数据操作Save, SaveAs, SaveOptions, SaveAsOptions和和WorksharingSaveAsOptionsOpen,OpenOptions和和DetachFromC
4、entralOptionOpenOptions openOptions = new OpenOptions();WorksetConfiguration config = openOptions.GetOpenWorksetsConfiguration();if (null = config) config = new WorksetConfiguration(); openOptions.SetOpenWorksetsConfiguration(config);config.OpenLastViewed();Document newDoc = RevitApp.OpenDocument(Op
5、enDocument.rvt), openOptions);ReloadLatestTransaction trans = new Transaction(RevitDoc, RL);trans.Start();ReloadLatestOptions options = new ReloadLatestOptions();RevitDoc.ReloadLatest(options);bool isUpdated = RevitDoc.HasAllChangesFromCentral();trans.Commit();SynchronizeWithCentralSynchronizeWithCe
6、ntralOptions options = new SynchronizeWithCentralOptions();options.Comment = Relinquish Options;RelinquishOptions newRelinqOptions = new RelinquishOptions(false);newRelinqOptions.CheckedOutElements = true;newRelinqOptions.StandardWorksets = false;options.SetRelinquishOptions(newRelinqOptions);Transa
7、ctWithCentralOptions transOptions = new TransactWithCentralOptions(); CallBack callInst = new CallBack();transOptions.SetLockCallback(callInst);RevitDoc.SynchronizeWithCentral(transOptions, options); Workset和WorksetTable WorksetDefaultVisibilitySettings WorksetVisibility ElementWorksetFilter Filtere
8、dWorksetCollector和WorksetKindFilter工作共享中的工作集管理工作共享中的工作集管理Workset和和WorksetTableWorksetTable worksetTable = RevitDoc.GetWorksetTable(); WorksetId activeId = worksetTable.GetActiveWorksetId();Workset activeWorkset = worksetTable.GetWorkset(activeId);Workset wallWorkset = worksetTable.GetWorkset(wall.Wo
9、rksetId);WorksetDefaultVisibilitySettingsWorksetDefaultVisibilitySettings defaultVisibility = WorksetDefaultVisibilitySettings.GetWorksetDefaultVisibilitySettings(RevitDoc);bool isVisible = defaultVisibility.IsWorksetVisible(worksetId);defaultVisibility.SetWorksetVisibility(worksetId, !isVisible);Wo
10、rksetVisibilityView view = getActiveView();WorksetVisibility visibility = view.GetWorksetVisibility(worksetId);view.SetWorksetVisibility(worksetId, WorksetVisibility.Hidden);visibility = view.GetWorksetVisibility(worksetId);view.SetWorksetVisibility(worksetId, WorksetVisibility.UseGlobalSetting);vis
11、ibility = view.GetWorksetVisibility(worksetId);view.SetWorksetVisibility(worksetId, WorksetVisibility.Visible);FilteredWorksetCollector collector = new FilteredWorksetCollector(RevitDoc);collector.OfKind(WorksetKind.UserWorkset);IList worksets = collector.ToWorksets();WorksetKindFilter standardFilte
12、r = new WorksetKindFilter(WorksetKind.StandardWorkset, true);collector.WherePasses(standardFilter);FilteredWorksetCollector和和WorksetKindFilterFilteredWorksetCollector(RevitDoc);collector.OfKind(WorksetKind.UserWorkset);WorksetKindFilter(WorksetKind.StandardWorkset, true);ElementWorksetFilterElementW
13、orksetFilter elmentWorksetFilter = new ElementWorksetFilter(worksetId, false);FilteredElementCollector collector = new FilteredElementCollector(RevitDoc);ICollection worksetElemsfounds = collector.WherePasses(elmentWorksetFilter).ToElements(); EnableWorksharing CheckoutElements和RelinquishOwnership工作
14、共享权限管理工作共享权限管理开启工作共享开启工作共享RevitDoc.EnableWorksharing(abc, def);Assert.IsTrue(RevitDoc.IsWorkshared);获得编辑权限获得编辑权限ICollection checkedOutElementIds = WorksharingUtils.CheckoutElements(RevitDoc, elementsToBeCheckedout);放弃编辑权限放弃编辑权限TransactWithCentralOptions transOptions = new TransactWithCentralOptions(
15、);RelinquishOptions relinqOptions = new RelinquishOptions(false);relinqOptions.CheckedOutElements = true;relinqOptions.FamilyWorksets = false;relinqOptions.StandardWorksets = false;relinqOptions.UserWorksets = false; relinqOptions.ViewWorksets = false; / relinquish checked out elementsRelinquishedIt
16、ems items = WorksharingUtils.RelinquishOwnership(RevitDoc, relinqOptions, transOptions); WorksharingDisplayMode WorksharingDisplaySettings WorksharingDisplayGraphicSettings工作共享的显示模式工作共享的显示模式WorksharingDisplayModeWorksharingDisplayMode wsDisplayMode = view.GetWorksharingDisplayMode(); view.SetWorksha
17、ringDisplayMode(WorksharingDisplayMode.CheckoutStatus); WorksharingDisplaySettingsDocument doc = RevitApp.OpenDocumentFile(Workshared.rvt);Transaction trans = new Transaction(doc, new trans);trans.Start();WorksharingDisplaySettings settings = WorksharingDisplaySettings.GetOrCreateWorksharingDisplayS
18、ettings(doc);ICollection users = settings.GetAllUsersWithGraphicOverrides();trans.Commit();GetGraphicOverrides(String)GetGraphicOverrides(CheckoutStatus)GetGraphicOverrides(ModelUpdatesStatus)GetGraphicOverrides(WorksetId)WorksharingDisplayGraphicSettingsusing (Transaction _transaction_ = new Transa
19、ction(RevitDoc) _transaction_.Start(GetGraphicOverrides_String); ICollection users = displaySettings.GetAllUsersWithGraphicOverrides(); foreach (String userName in users) WorksharingDisplayGraphicSettings graphicSettings = displaySettings.GetGraphicOverrides(userName); _transaction_.Commit();WorksharingDisplayGraphicSettings graphicSettings = new WorksharingDisplayGraphicSettings(true, new Color(255, 0, 0);displaySettings.SetGraphicOverrides(CheckoutStatus.NotOwned, graphicSettings); DocumentSynchronizingWithCentral DocumentSynchronizedWithCentral工作共享中的事件工作共享中的事件Q&A
侵权处理QQ:3464097650--上传资料QQ:3464097650
【声明】本站为“文档C2C交易模式”,即用户上传的文档直接卖给(下载)用户,本站只是网络空间服务平台,本站所有原创文档下载所得归上传人所有,如您发现上传作品侵犯了您的版权,请立刻联系我们并提供证据,我们将在3个工作日内予以改正。