我想获得一些VBA代码,它会告诉我Catia绘图中的纸张数量。每张表都有一个标题栏。每个标题栏上的文本字段将传达工作表的数量。因此,如果您在图纸中有三张纸,则您将拥有3张中的1张(在标题栏表1中)2张中的3枚(在标题栏shhet 2中)和3张中的3张(在标题栏表3中)。如果宏可以自动更新所有工作表上的所有标题栏。
任何帮助都非常感激。
答案 0 :(得分:1)
概念是遍历Sheets
DrawingDocument
集合中的DrawingText
个对象,您应该将所有标题块元素放在“背景视图”中。接下来,我们需要更新或创建现有的标题栏文本元素。这些是DrawingText
个对象。我们尝试按名称访问Option Explicit
Sub UpdateSheetPage()
Dim DrawingDoc As DrawingDocument
Dim DSheet As DrawingSheet
Dim DView As DrawingView
Dim SheetCount As Integer
Dim currentSheet As Integer
'the drawing must be the active docuement window or this will fail. you can do more error checking if needed
On Error GoTo ExitSub
Set DrawingDoc = CATIA.ActiveDocument
SheetCount = DrawingDoc.Sheets.Count
currentSheet = 1 'initialize sheet number
'loop through all sheets and update or create a sheet number
For Each DSheet In DrawingDoc.Sheets
UpdatePageNumber DSheet, currentSheet, SheetCount
currentSheet = currentSheet + 1
Next
ExitSub:
End Sub
Sub UpdatePageNumber(currentDrawingSheet As DrawingSheet, currentSheetNumber As Integer, totalSheets As Integer)
Dim sheetNumber As String
Dim xPos, yPos As Long 'mm
'edit these if needed
xPos = 100 'edit this - only use for new creation
yPos = 100 'edit this
'display format
sheetNumber = "Page " & currentSheetNumber & "/" & totalSheets
Dim backgroundView As DrawingView
Dim dTexts As DrawingTexts
Dim currentText As DrawingText
Set backgroundView = currentDrawingSheet.Views.Item("Background View")
Set dTexts = backgroundView.Texts
On Error GoTo CreateNew
Set currentText = dTexts.GetItem("SheetNumber")
currentText.Text = sheetNumber
Exit Sub
CreateNew:
Set currentText = dTexts.Add(sheetNumber, xPos, yPos)
currentText.Name = "SheetNumber" 'so we can access it later for an update
End Sub
(这必须是独一无二的!)。如果它不存在,我们创建它。如果确实存在,我们会更新该值。
这是制作标题栏的开始:
var pb = $("#profileCompleteness").kendoProgressBar({
type: "chunk",
chunkCount: xChunkCount,
min: 0,
max: xChunkCount,
value: 0,
orientation: "vertical"
}).data("kendoProgressBar");