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 ?
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.
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 SubRegards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: Catia Macro - Add geometrical set.
This line is highlighted:
Set hybridBody1 = hybridBodies1.Item(mySelection.Name)
Link
RE: Catia Macro - Add geometrical set.
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: Catia Macro - Add geometrical set.
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.
Second question - only if you will modify the code...now you have the example
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: Catia Macro - Add geometrical set.