''' <summary> ''' 判断当前打开绘图是否包含表格 ''' </summary> ''' <returns>当前打开绘图是否包含表格</returns> PrivateFunction HasTable() AsBoolean Dim model As IpfcModel Dim tableOwner As IpfcTableOwner Dim tables As IpfcTables HasTable = False model = asyncConnection.Session.CurrentModel tableOwner = CType(model, IpfcTableOwner) tables = tableOwner.ListTables() If tables IsNothingThen ReturnFalse EndIf If tables.Count = 0Then ReturnFalse EndIf ReturnTrue EndFunction
''' <summary> ''' 返回包含&&rpt.index的表格ID,即包含BOM的表格 ''' </summary> ''' <returns>返回包含包含BOM的表格ID</returns> PrivateFunction TableIDwithBom() AsInteger Dim model As IpfcModel Dim tableOwner As IpfcTableOwner Dim tables As IpfcTables Dim table As IpfcTable Dim tableCell As IpfcTableCell Dim cellnote As IpfcModelItem Dim detailNoteItem As IpfcDetailNoteItem Dim detailNoteInstructions As IpfcDetailNoteInstructions Dim i, j AsInteger 'CREO表格的序号从1开始 TableIDwithBom = Integer.MinValue Try If Isdrawding() = TrueThen If HasTable() = TrueThen model = asyncConnection.Session.CurrentModel tableOwner = CType(model, IpfcTableOwner) tables = tableOwner.ListTables() tableCell = (New CCpfcTableCell).Create(1, 1) ForEach table In tables For i = 1To table.GetRowCount() For j = 1To table.GetColumnCount() tableCell.RowNumber = i tableCell.ColumnNumber = j cellnote = table.GetCellNote(tableCell) If cellnote IsNotNothingThen If cellnote.Type = EpfcModelItemType.EpfcITEM_DTL_NOTE Then detailNoteItem = CType(cellnote, IpfcDetailNoteItem) detailNoteInstructions = detailNoteItem.GetInstructions(True) If detailNoteInstructions.TextLines.Item(0).Texts.Count > 0Then If (detailNoteInstructions.TextLines.Item(0).Texts.Item(0).Text = "&rpt.index") Then TableIDwithBom = table.Id Return TableIDwithBom EndIf EndIf EndIf EndIf Next Next Next EndIf EndIf Catch ex As Exception MsgBox(ex.Message.ToString + Chr(13) + ex.StackTrace.ToString) EndTry Return TableIDwithBom EndFunction
''' <summary> ''' 水平排列 ''' </summary> Horizon = 1 EndEnum ''' <summary> ''' 排列球标符号 ''' </summary> ''' <param name="palcement">排列方式,水平还是垂直</param> PrivateSub PlaceBallon(ByVal palcement As Placement) Dim modelitem As IpfcModelItem Dim selections As IpfcSelectionBuffer Dim selectBalloon As IpfcSelection Dim point As CpfcPoint3D Dim i AsInteger Dim item As IpfcDetailSymbolInstItem Dim detailSymbolDefInstructions As IpfcDetailSymbolInstInstructions Dim leaders As IpfcDetailLeaders Dim attachment As IpfcFreeAttachment Dim detailItemOwner As IpfcDetailItemOwner Try If Isdrawding() = TrueThen detailItemOwner = CType(asyncConnection.Session.CurrentModel, IpfcDetailItemOwner) '鼠标点选一个点作为垂直排列球标的横坐标 point = MousePoint() '获取所有选定的对象,确保选中的都是球标 selections = asyncConnection.Session.CurrentSelectionBuffer For i = 0To selections.Contents.Count - 1 selectBalloon = selections.Contents.Item(i) modelitem = selectBalloon.SelItem '国标化球标将球标变成了一个可以访问的DTL_SYM_INSTANCE,未国标化操作的球标无法完成以下操作 If modelitem IsNothingThen ContinueFor EndIf If modelitem.Type = EpfcModelItemType.EpfcITEM_DTL_SYM_INSTANCE Then item = CType(modelitem, IpfcDetailSymbolInstItem) '获得原始球标放置的信息 detailSymbolDefInstructions = item.GetInstructions(True) leaders = detailSymbolDefInstructions.InstAttachment attachment = leaders.ItemAttachment '修改放置位置横坐标值为选中的坐标 If palcement = Placement.Horizon Then attachment.AttachmentPoint.Set(1, point.Item(1)) Else attachment.AttachmentPoint.Set(0, point.Item(0)) EndIf leaders.ItemAttachment = attachment detailSymbolDefInstructions.InstAttachment = leaders '球标重新放置放置 item.Modify(detailSymbolDefInstructions) EndIf Next Reg_Csheet() EndIf Catch ex As Exception MsgBox(ex.Message.ToString + Chr(13) + ex.StackTrace.ToString) EndTry EndSub