CATIA V5 VBA中是否有返回当前打开文件名称的命令或字符串?



我正在制作一个宏,在Catia v5中做一些动作,我通过记录它得到了所有的代码,它的工作奇迹!但是,现在我希望能够在另一个catproduct, catpart等上运行代码。但是不需要手动更改代码上的文件名。

代码:

Sub CATMain()
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.Add("AutomaticNaming")
Dim drawingViewGenerativeLinks1 As DrawingViewGenerativeLinks
Set drawingViewGenerativeLinks1 = drawingView1.GenerativeLinks
Dim drawingViewGenerativeBehavior1 As DrawingViewGenerativeBehavior
Set drawingViewGenerativeBehavior1 = drawingView1.GenerativeBehavior
Dim documents1 As Documents
Set documents1 = CATIA.Documents
Dim productDocument1 As ProductDocument
Set productDocument1 = documents1.Item("*FILENAME.CATProduct*")
Dim product1 As Product
Set product1 = productDocument1.Product
drawingViewGenerativeBehavior1.Document = product1
drawingViewGenerativeBehavior1.DefineIsometricView 0.707107, 0.707107, 0#, -0.408248, 0.408248, 0.816497
drawingView1.X = -1262.192063
drawingView1.Y = -1262.192063
drawingView1.[Scale] = 1#
Set drawingViewGenerativeBehavior1 = drawingView1.GenerativeBehavior
drawingViewGenerativeBehavior1.Update
Set drawingViews1 = drawingSheet1.Views
Set drawingView1 = drawingViews1.Add("AutomaticNaming")
Set drawingViewGenerativeLinks1 = drawingView1.GenerativeLinks
Set drawingViewGenerativeBehavior1 = drawingView1.GenerativeBehavior
Set documents1 = CATIA.Documents
Set productDocument1 = documents1.Item("FILENAME.CATProduct")
Set product1 = productDocument1.Product
drawingViewGenerativeBehavior1.Document = product1
drawingViewGenerativeBehavior1.DefineIsometricView -0.707107, 0.707107, 0#, -0.408248, -0.408248, 0.816497
drawingView1.X = 7266.177117
drawingView1.Y = -1262.192063
drawingView1.[Scale] = 1#
Set drawingViewGenerativeBehavior1 = drawingView1.GenerativeBehavior
drawingViewGenerativeBehavior1.Update

End Sub

使用Document对象的NameFullName属性

CATIA.ActiveDocument.Name 'returns the name of the active document
CATIA.ActiveDocument.FullName ' returns the full path to the document including the name

在你的情况下,既然你分配了CATIA.ActiveDocument,你可以只使用DrawingDocument1.NameDrawingDocument1.FullName

最新更新