A-A+

CATIA使用VBA(VBS)二次开发时工程图和草图位置的交互选择函数Indicate2D

2020年01月23日 CAD 阅读 1,127 views 次

在CATIA中使用VBA(VBS)进行二次开发时,在工程图或草图中可以使用Document类下的Indicate2D方法进行用户交互选择。

Indicate2D函数让用户在工程图或草图中用鼠标点击一个位置,然后返回此鼠标点击位置用于元素的放置或获取鼠标点击位置的坐标。函数的定义如下所示:

Func Indicate2D( CATBSTR iMessage, CATSafeArrayVariant ioDocumentWindowLocation) As CATBSTR

各参数含义如下:

iMessage:在状态栏上显示的提示信息;

ioDocumentWindowLocation:用于存储鼠标点击点坐标的矩阵,ioDocumentWindowLocation(0)为x,ioDocumentWindowLocation(1)为y。

可能返回的值为"Normal"(成功)、"Cancel"、"Undo"或"Redo"。如果在草绘中调用该函数,必须在Sketch.OpenEdition函数调用之后且Sketch.CloseEdition函数没有调用之前使用该函数。

示例代码:在工程图上用鼠标点击一个位置,放置文字Hello world。

Sub CATMain()Set Document = CATIA.ActiveDocument : Set Selection = Document.Selection : Set DrawingSheets = Document.Sheets Set DrawingSheet = DrawingSheets.ActiveSheet : Set DrawingViews = DrawingSheet.ViewsSet DrawingView = DrawingViews.ActiveView : Set DrawingTexts = DrawingView.TextsDim DrawingWindowLocation(1)Status=Document.Indicate2D("select a location into the drawing window",DrawingWindowLocation)if (Status = "Cancel") then Exit SubSet DrawingText = DrawingTexts.Add("Hello world",DrawingWindowLocation(0),DrawingWindowLocation(1)) End Sub

关于在CATIA VBA(VBS)二次开发中元素的交互选择方法可参考文章《CATIA使用VBA(VBS)二次开发时用户的交互选择》

个人公众号“数字化设计CAX联盟”,欢迎关注,共同交流
为您推荐:

给我留言

© 坐倚北风 版权所有 严禁镜像复制 苏ICP备15034888号. 基于 Ality 主题定制 AliCMS
联系邮箱:leanwind@163.con,微信公众号:数字化设计CAX联盟

用户登录

分享到: