PrivateFunction StrstoTextlines(ByVal Texts AsString) As CpfcDetailTextLines Dim detailText As IpfcDetailText Dim detailTexts As CpfcDetailTexts Dim textLine As IpfcDetailTextLine Dim i AsInteger Dim Strs() AsString '将String赋值给textLines StrstoTextlines = New CpfcDetailTextLines Strs = Split(Texts, Chr(10)) '根据回车符分割确定行数 '根据行数创建对象并添加内容 For i = 0To Strs.Length - 1 detailText = (New CCpfcDetailText).Create(Strs(Strs.Length - i - 1)) '注意顺序 detailTexts = New CpfcDetailTexts detailTexts.Insert(0, detailText) textLine = (New CCpfcDetailTextLine).Create(detailTexts) StrstoTextlines.Insert(0, textLine) Next EndFunction
PrivateFunction MousePosAttatchement() As IpfcFreeAttachment Dim point As CpfcPoint3D Dim mouse As IpfcMouseStatus '鼠标左键点选注解放置的位置 point = New CpfcPoint3D mouse = asyncConnection.Session.UIGetNextMousePick(EpfcMouseButton.EpfcMOUSE_BTN_LEFT) point = mouse.Position MousePosAttatchement = (New CCpfcFreeAttachment).Create(point) Return MousePosAttatchement EndFunction
PublicSub CreateNoteWithoutLeader(ByVal Texts AsString) Dim model As IpfcModel Dim drawing As IpfcDrawing Dim textLines As CpfcDetailTextLines Dim noteInstructions As IpfcDetailNoteInstructions Dim note As IpfcDetailNoteItem Dim position As IpfcFreeAttachment Dim allAttachments As IpfcDetailLeaders If Isdrawding() = TrueThen model = asyncConnection.Session.CurrentModel drawing = CType(model, IpfcDrawing) 'String转CpfcDetailTextLines textLines = StrstoTextlines(Texts) '鼠标左键点选注解放置的位置 position = MousePosAttatchement() '设置Attachments allAttachments = (New CCpfcDetailLeaders).Create() allAttachments.ItemAttachment = position '设置noteInstructions noteInstructions = (New CCpfcDetailNoteInstructions).Create(textLines) noteInstructions.Leader = allAttachments '创建note并显示 note = drawing.CreateDetailItem(noteInstructions) note.Show() EndIf EndSub
PrivateFunction SelectEdge() As IpfcSelection Dim selections As CpfcSelections Dim selectionOptions As IpfcSelectionOptions selectionOptions = (New CCpfcSelectionOptions).Create("edge") selectionOptions.MaxNumSels = 1 selections = asyncConnection.Session.Select(selectionOptions, Nothing) SelectEdge = selections.Item(0) Return SelectEdge EndFunction
PublicSub CreateNoteWithLeader(ByVal Texts AsString) Dim model As IpfcModel Dim drawing As IpfcDrawing Dim selectedEdge As IpfcSelection '选择获取一个边 Dim leader As IpfcParametricAttachment Dim allAttachments As IpfcDetailLeaders Dim position As IpfcFreeAttachment Dim textLines As CpfcDetailTextLines Dim noteInstructions As IpfcDetailNoteInstructions Dim note As IpfcDetailNoteItem Dim attachments As CpfcAttachments If Isdrawding() = TrueThen model = asyncConnection.Session.CurrentModel drawing = CType(model, IpfcDrawing) textLines = StrstoTextlines(Texts) '鼠标左键点选注解放置的位置 position = MousePosAttatchement()
''''''''''''''''''''''''''''''''''''''''''''''''' '相比自由注解添加的步骤 '生成一个IpfcParametricAttachment selectedEdge = SelectEdge() leader = (New CCpfcParametricAttachment).Create(selectedEdge) '生成引出对象序列,这里只设置一个 attachments = New CpfcAttachments attachments.Insert(0, leader) ''''''''''''''''''''''''''''''''''''''''''''''''' '设置Attachments allAttachments = (New CCpfcDetailLeaders).Create() allAttachments.ItemAttachment = position ''''''''''''''''''''''''''''''''''''''''''''''''' '相比自由注解添加的步骤 allAttachments.Leaders = attachments ''''''''''''''''''''''''''''''''''''''''''''''''' '设置noteInstructions noteInstructions = (New CCpfcDetailNoteInstructions).Create(textLines) noteInstructions.Leader = allAttachments '创建note并显示 note = drawing.CreateDetailItem(noteInstructions) note.Show() EndIf EndSub