在CATIA更改剖视文本(Change cut view text in CATIA)

2019-10-19 18:40发布

我目前正在与CATIA V5的工作,我想用宏(VBA),但我有一些问题!

我的问题是:如何更改切割视图的文本? (见图)

我试图用:myView.Texts.item(1)来访问这个“文”,但我认为CATIA不认为这是文本 ...

我想改变这个文本,而无需用户(不选择)的介入,我能做到吗?

Answer 1:

IME,起草工作台VBA脚本是在第一相当棘手......“MyTexts”是DrawingText对象的集合。

MyDrawingText.Text = "MyNewTextValue"

你将有主要麻烦越来越要修改特定的文本对象的句柄。 我发现,解决这个问题的最好办法是,要么扫描的DrawingView整个DrawingTexts收集,并运用独特的名字, DrawingText.Name="UniqueObjectName" ,或者您从脚本绘图文字,你可以更容易地获得处理DrawingText对象上把你在那里想要的任何值。 创造独特的名称,使您的图纸为未来的脚本更稳健

MyView.Texts.Count也将是有益的获得该项目数,如果最后创建DrawingText对象(S)。

我很高兴能进一步解释,如果你需要。 祝好运!

更新/编辑:正如上面提到的,脚本与起草工作台并不总是直线前进。 事实证明,标注文字不完全生活在DrawingTexts一个集合DrawingView ,但他们有地方住图纸视图内......在这种情况下,你要编辑的剖面视图的“ID”。 。那财产不通过VBA暴露无论是。

有一个hack /变通办法是搜索父视图绘制文本,然后用一些逻辑,你需要拿出,扫描Selection你要更改的文本。 您应该重命名,然后当你在它,这样它更容易回来,并再次找到他们。

这里的开始与前视图的对象分辨率(剖面视图的父视图)的示例

Sub ChangeCallout()

'---- Begin resolution script for object : Front View

Dim drawingDocument1 As DrawingDocument
Set drawingDocument1 = CATIA.ActiveDocument

Dim drawingSheets1 As DrawingSheets
Set drawingSheets1 = drawingDocument1.Sheets

Dim drawingSheet1 As DrawingSheet
Set drawingSheet1 = drawingSheets1.Item("Sheet.1")

Dim drawingViews1 As DrawingViews
Set drawingViews1 = drawingSheet1.Views

Dim drawingView1 As DrawingView
Set drawingView1 = drawingViews1.Item("Front view") 'this is the parent view of the section view

'---- End resolution script

Dim sel As Selection
Set sel = drawingDocument1.Selection
Dim CalloutText As drawingText

sel.Clear 'clear the selection / good practice
sel.Add drawingView1 'add the parent view to the selection
sel.Search "Drafting.Text,sel" 'this will search the current selection for all drawing texts and add them to the selection

Dim thing As Variant
Dim i As Integer
For i = 1 To sel.Count
    Set thing = sel.Item2(i)
    Set CalloutText = thing.Value
    'do some things/logic here to determine if this is a callout with some Ifs or Case statements
    'CalloutText.Name = "Useful Unique Name"
    'CalloutText.Text = "New Callout Label" 'whatever you want to rename it to
Next

End Sub


Answer 2:

在切割视图的文本由视图名称定义的,要改变它,你应该更改视图名称描述波纹管:

Sub CATMain()

    Dim oDraw As DrawingDocument
    Set oDraw = CATIA.ActiveDocument

    Dim oSectionView As DrawingView
    Set oSectionView = oDraw.Sheets.ActiveSheet.Views.ActiveView

    oSectionView.SetViewName "Prefix ", "B", " Suffix"

End Sub


Answer 3:

对于通过标注文本扫描您可以使用下面行。 这将选择属于只标注文本,并通过所有文字不扫描。

Sub CATMain()

Dim drawingDocument1 As Document
Set drawingDocument1 = CATIA.ActiveDocument

Dim selection1 As Selection
Set selection1 = drawingDocument1.Selection

selection1.Search "CATDrwSearch.DrwCallout,all"
selection1.Search "Drafting.Text,sel"

Dim i As Integer

For i = 1 To selection1.Count

MsgBox selection1.Item(i).Value.text

Next

End Sub


文章来源: Change cut view text in CATIA