CATIA V5 VBA 中是否有命令或字符串 returns 当前打开文件的名称?
Is there a command or string in CATIA V5 VBA that returns the name of the current open file?
我正在制作一个在 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
使用文档对象的 Name
或 FullName
属性。
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.Name
或 DrawingDocument1.FullName
.
我正在制作一个在 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
使用文档对象的 Name
或 FullName
属性。
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.Name
或 DrawingDocument1.FullName
.