sdunn 发表于 2018-2-26 14:32:48

Civil 3D将块添加到点标签样式

我正在尝试将块组件添加到点标签样式中。 我还没有弄清楚如何在创建组件后分配块名称。 我唯一能找到的是组件。这是可能的,还是我错过了一些简单的东西?
      Private Sub addBlockComponent(ByVal style As LabelStyle, ByRef blknam As String, blkht As Double)
            Dim id As ObjectId = style.AddComponent("Block", LabelStyleComponentType.Block)
            Dim component As LabelStyleBlockComponent = TryCast(id.GetObject(OpenMode.ForWrite), LabelStyleBlockComponent)
            component.Block.BlockName.Value = blknam
            component.Block.Attachment.Value = BlockAttachmentType.MiddleCenter
            component.Block.BlockHeight.Value = blkht
            component.Block.RotationAngle.Value = 0
      End Sub

**** Hidden Message *****

Jeff_M 发表于 2018-2-26 17:53:02

在 C3D 2018 中,BlockName.Value 属性为 get/set,因此您可以分配要使用的块。但是,高度和旋转值仅获取。我发现文档上写满了 Block 的所有内容,属性仅获取,但 BlockName、Attachment、XOffset 和 YOffset 都是 get/set。以下 c# 代码适用于我: 。
公共 void testsetting()。
{。
CivilDocument civdoc = (CivilDocument)CivilApplication.ActiveDocument;。
using (AcDb.Transaction tr = AcDb.HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction())。
{。
LabelStyle labelStyle = (LabelStyle)tr.GetObject(civdoc.Styles.LabelStyles.PointLabelStyles.LabelStyles, AcDb.OpenMode.ForWrite);。
var compId = labelStyle.AddComponent(“TheBlock”, labelStyleComponentType.Block);。
var comp = (LabelStyleBlockComponent)tr.GetObject(compId, AcDb.OpenMode.ForWrite);。
比较Block.BlockName.Value = “bound”;必须存在于图形中。
比较Block.Attachment.Value = Autodesk.Civil.BlockAttachmentType.MiddleCenter;。
比较Block.XOffset.Value = (.1/12);。
比较Block.YOffset.Value = (.1/12);。
断续器Commit();。
}。
}。

sdunn 发表于 2018-2-27 11:46:49

谢谢你杰夫!
页: [1]
查看完整版本: Civil 3D将块添加到点标签样式