pBe 发表于 2019-4-11 08:00:29

工作表自定义属性

需要帮助: private void TheSetSheetCustomProperty(IAcSmPersist owner, Dictionary kval)。
{。
Autodesk.AutoCAD.ApplicationServices.Document activeDocument;。
activeDocument = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;。

创建对自定义属性包的引用。
AcSmCustomPropertyBag customPropertyBag = default(AcSmCustomPropertyBag);。

如果(所有者,GetTypeName() == “AcSmSheet”)。
{。
AcSmSheet sheet = (AcSmSheet)owner;。
customPropertyBag = sheet.GetCustomPropertyBag();。
IAcSmEnumProperty enumeratorProperty;。
enumeratorProperty = customPropertyBag.GetPropertyEnumerator();。

AcSmCustomPropertyValue customPropertyValue = null;。
enumeratorProperty.Next(out string name, out customPropertyValue);。

而 (!(customPropertyValue == null))。
{。
// if (name == propertyName)。
if (kval.包含键(名称) == true)。
{。
customPropertyValue.SetValue(kval); // 。
customPropertyBag.SetProperty(name, customPropertyValue); // 。
}。
enumeratorProperty.Next(out name, out customPropertyValue);。
}。
}。
}IF 的计算结果为 TRUE,但未设置字符串值。我错过了什么?是的,自定义属性名称存在于 DST 文件上。。
**** Hidden Message *****

pBe 发表于 2019-4-12 17:39:59

我经常使用例程来修改自定义工作表集属性&我使用AcSmCustomPropertyValue.SetProperty()属性方法,我不认为我使用了AcSmCustomPropertyBag.SetProperty(),但在您的示例中,它似乎会将属性设置回原始值。customPropertyValue.SetValue(kval); // 。
customPropertyBag.SetProperty); // 。

pBe 发表于 2019-4-15 02:21:05

嗨,杰夫,
感谢您的回复。
我添加了该行,认为它会在设置所需的字符串后“重新生成”或更新值。现在我评论了这一行。
customPropertyBag.SetProperty(name, customPropertyValue)
它没有区别。
至于
AcSmCustomPropertyValue.SetProperty()
。这是我的第一个想法,但它不是AcSmCustomPropertyValue的有效定义。
我需要调用保存吗?
AcSmCustomPropertyValue.Save
c# 中是否有类似的函数从工作表集定义中检索项目,就像下面的 l 方法一样?
vla-item Sheets "The Custom Property Name"
谢谢

pBe 发表于 2019-4-15 13:55:20

我会仔细检查,但我记得你在数据库上调用保存。

pBe 发表于 2019-4-15 17:27:06

谢谢你的帮助杰夫。
我发现出了什么问题。我在代码的底部有这一行。
SyncProperties(sheetSetDatabase)
将 Custom 属性中的值向下传递到子集行。我从AU09_Presentation_CP318-4我的坏地方捡到它

其他项目。
我用它来打开一个图纸集文件
doc。SendStringToExecute(“._-opensheetset ” + yourSheetSetFilePath + “\n”, false, false, true);
现在的问题是。如何从图纸集管理器关闭打开的图纸集?

pBe 发表于 2019-4-22 12:51:04

我相信你可以,但我从来没有这样做过。在代码执行之前,我通常只需要在sheetsetmanager中打开一个图纸集。
页: [1]
查看完整版本: 工作表自定义属性