catia 二次开发:获得投影视图

该博客详细介绍了如何使用CATIA软件创建工程图文档,包括添加新页面、设置页面参数、创建主视图和投影视图,并对视图进行定位、对齐和更新。此外,还展示了如何将3D模型关联到视图中,以及复制主视图的关联关系到投影视图上。
摘要由CSDN通过智能技术生成

在这里插入图片描述
在这里插入图片描述

Sub kj()
Dim oDrawingDoc As DrawingDocument
Set oDrawingDoc = CATIA.Documents.Add("Drawing") '创建工程图文档

Dim oSheet As DrawingSheet
Set oSheet = oDrawingDoc.Sheets.Add("FirstSheet") '创建一个页面
'页面设置
'oDrawingDoc.Standard = catISO
'oSheet.PaperSize = catPaperA1
'oSheet.Scale2 = 1
'oSheet.Orientation = catPaperLandscape
oSheet.[Scale] = 1
Dim oFrontView As DrawingView
'主视图的操作------------
Set oFrontView = oSheet.Views.Add("FrontView") '添加视图对象
'Set oFrontView = oSheet.Views.ActiveView
Dim oFrontViewGB As DrawingViewGenerativeBehavior
Set oFrontViewGB = oFrontView.GenerativeBehavior

Dim PartToDraw As PartDocument
Set PartToDraw = CATIA.Documents.Item("bolt.CATPart")
oFrontViewGB.Document = PartToDraw 'GenerativeBehavior的document属性关联3D模型
oFrontViewGB.DefineFrontView 0, 0, 1, 0, 1, 0 '定义主视图
'oFrontView.x = 550
'oFrontView.y = 425
'更新主视图
oFrontViewGB.Update

'在主视图的基础上的投影视图的操作-----------
Dim oLeftView As DrawingView
Set oLeftView = oSheet.Views.Add("leftView")
Dim oLeftViewGB As DrawingViewGenerativeBehavior
Set oLeftViewGB = oLeftView.GenerativeBehavior
oLeftViewGB.DefineProjectionView oFrontViewGB, catLeftView

Dim oFrontViewLinks As DrawingViewGenerativeLinks
Set oFrontViewLinks = oFrontView.GenerativeLinks
Dim oLeftViewLinks As DrawingViewGenerativeLinks
Set oLeftViewLinks = oLeftView.GenerativeLinks '各种获取links
oFrontViewLinks.CopyLinksTo oLeftViewLinks '主视图和零件的关联关系复制给左视图:
oLeftViewGB.Update

oLeftView.ReferenceView = oFrontView
oLeftView.AlignedWithReferenceView '对齐关系

oLeftView.x = 100
'oLeftView.y = 100 '水平对齐后,y方向就没必要移动了
End Sub

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值