catia切割红色框框_在CATIA中更改切割视图文本

I'm currently working with CATIA V5, and I want to use Macros (VBA), but I have some problems!

My question is: how to change the text of a cut view? (see the picture)

I tried to use : myView.Texts.item(1) to access to this "text" but I think that CATIA dont consider it as text...

I want to change this text without the intervention of the user ( without selections), can I do that?

解决方案

IME, VBA scripting in drafting workbench is quite tricky at first..."MyTexts" is a collection of DrawingText objects.

MyDrawingText.Text = "MyNewTextValue"

The main trouble you will have is getting a handle on the specific text object that you want to modify. I found that the best way around this is to either scan the entire DrawingTexts collection in the DrawingView, and apply a unique name, DrawingText.Name="UniqueObjectName", or you create the drawing text from the script and you can more easily get a handle on the DrawingText object to put whatever value you want in there. Creating Unique Names makes your drawing more robust for future scripting

MyView.Texts.Count will also be useful to get the item number if the last created DrawingText object(s).

I'm happy to further explain if you need. Good luck!

Update/Edit:

As mentioned above, scripting with the drafting workbench is not always straight forward. It turns out that the callout texts do not exactly live in the DrawingTexts collection of a DrawingView, but they do live somewhere inside the drawing view...In this case, you're trying to edit the "ID" of the section view..That property isn't exposed through VBA either.

There is a hack/work-around which is to search the parent view for drawing texts and and then with some logic, which you'll need to come up with, scan the Selection for the texts you want to change. You should rename then while you're at it, this way it's easier to come back and find them again.

Here's an example starting with an Object Resolution of the Front View (the parent view of the section view)

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值