×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

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

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

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

(OP)
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

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

Hi,

Welcome to Eng-Tips....

1.

CODE --> CATScript

' 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 --> CATScript

' 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

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

(OP)
Thanks Dear. You saved my day. Thanks a Lot

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

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources