×
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 - Add geometrical set.

Catia Macro - Add geometrical set.

Catia Macro - Add geometrical set.

(OP)
Hello, i would like to create macro, which insert new geometrical.set into one selected. I found some examples on internet, and i have created something like this:

Language="VBSCRIPT"
Sub CATMain()

Set partDocument1 = CATIA.ActiveDocument
Set part1 = partDocument1.Part


Set hybridBodies1 = part1.HybridBodies
Set hybridBody2 = hybridBodies1.Add()

hybridBody2.Name = "NEW GEOMETRICAL SET"

part1.InWorkObject = hybridbody2
part1.Update

End Sub

But it inserts geometrical.set into root directory, what should i add to insert geometrical.set into selected geometrical.set.
Is there any posibility to apply hotkey to created macro ?

RE: Catia Macro - Add geometrical set.

Hi,

Should be something like this...

CODE --> CATScript

Language="VBSCRIPT"

Sub CATMain()

Dim partDocument1 As Document
Set partDocument1 = CATIA.ActiveDocument

Dim part1 As Part
Set part1 = partDocument1.Part

Dim hybridBodies1 As HybridBodies
Set hybridBodies1 = part1.HybridBodies

Dim oInputType(0)
Dim oStatus
Dim oSelection
Set oSelection = CATIA.ActiveDocument.Selection

	Dim Message, Style, Title, Response, MyString
	Message = ("This macro will a new GS in a selected one."  &_
							(chr(13)) &_
							(chr(13)) &_
						 "	- The active document window must be a CATPart "&_
							(chr(13)) &_
							(chr(13)) &_
"	Do you want to continue ?")
	Style = vbYesNo + vbDefaultButton2    'Define buttons.
	Title = "Purpose "   
	Response = MsgBox(Message, Style, Title)

	If Response = vbNo Then    
		Exit Sub
		Else
	End If

oInputType(0) = "HybridBody"
oStatus = oSelection.SelectElement2(oInputType, "Select a Geometrical Set", True)
If (oStatus = "Cancel") Then
Exit Sub
End If
Set mySelection = oSelection.Item(1).Value

Dim hybridBody1 As HybridBody
Set hybridBody1 = hybridBodies1.Item(mySelection.Name)

part1.InWorkObject = hybridBody1

Dim hybridBodies2 As HybridBodies
Set hybridBodies2 = hybridBody1.HybridBodies

Dim hybridBody3 As HybridBody
Set hybridBody3 = hybridBodies2.Add()

hybridBody3.Name = "NEW_GS"
part1.Update 

End Sub 

Regards
Fernando

https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...

RE: Catia Macro - Add geometrical set.

(OP)
Thank you for your answer, but when i try to run this script i get error.

This line is highlighted:

Set hybridBody1 = hybridBodies1.Item(mySelection.Name)

Link

RE: Catia Macro - Add geometrical set.

(OP)
I'm new in Catia scripting so if you could say me how to run it in CATScript instead of catvbs it would be nice :)
I got one extra question, is there any posibility to make this script working when i have CATproduct opened instead of CATPart in new window ?

RE: Catia Macro - Add geometrical set.

(OP)
I gather that i have to solve this problem on my own :P

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