Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Catia Macro: How to get Product/Part Object from MyDrawingView.GenerativeBehavior.Document.Parent

Status
Not open for further replies.

jagandeep

Automotive
May 27, 2013
82
IN
Hello World,
This is my first post in this forum. I want to get product/part object to parent document of drawing view. I know we can get full path of the same with following Statement.

MyDrawingView.GenerativeBehavior.Document.Parent.FullPath

But I have following problems

1. How can I get object to Parent 3D model without opening it ?
2. How to find if 3D Parent Model is already opened and switch to same ?

Jagandeep
 
Replies continue below

Recommended for you

Hi,

Welcome to Eng-Tips....

1.
Code:
  ' Get the document from the view
  Set oDocToOpen = MyDrawingView.GenerativeBehavior.Document.Parent
  ' open the document 
  OpenDoc(oDocToOpen.FullName)
  'Activate the opened document if already opened
  oDocToOpen.Activate
2.
Send the full name of the linked file to this function. it check the documents opened if opened then
Code:
' Opens a document
'	 Input 	- Document's Full Name with path
' 	 Output	- Document opened and activated
Function OpenDoc(oDocName)
	' Declaration
	Dim oProdFile
	If (NOT(Len(oDocName) = 0)) Then
		If (NOT(IsOpen(oDocName))) Then
			Set oProdFile = CATIA.Documents.Open(oDocName)
			oProdFile.Activate
		End If
		Set oProdFile = Nothing
	End If
End Function
' Check the document is open or not
'	Input 	- Document's Name with or without filepath
' 	Output	- TRUE, If Document is opened already in session
'		- FALSE, If not opened
Function IsOpen(ByVal oDocName)
	IsOpen = FALSE
	' Declaration
	Dim oTmpWnds, oTmpWnd
	Set oTmpWnds = CATIA.Windows
	oDcNm = Right(oDcNm, Len(oDocName) - InStrRev(oDocName, "\"))
	If NOT(oTmpWnds.Count = 0) Then
		For Each oTmpWnd in oTmpWnds
			If (UCase(oTmpWnd.Name) = UCase(oDocName)) Then
				IsOpen = TRUE
			End If
		Next
	End If
	Set oTmpWnds = Nothing
	Set oTmpWnd = Nothing
End Function

Regards,
Maddy
 
You are welcome..

Regards,
Maddy

The willingness to share knowledge does not make one charitable; it makes one self-reliant to know more.
Modified - Courtesy of Robert Brault

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top