(VBScript) Without the Selection, How to Add Bodies on the Product?
(VBScript) Without the Selection, How to Add Bodies on the Product?
(OP)
Hello, Guys
I think this is very simple script, but I can't make it.
I made a script to add bodies on Product, not open the window a part.
Of course, I can make it with the selection.
But I don't know how to add bodies without the selection on the Product.
Could you check below my scripts?
The first script is with the Selection, the second script is without the selection.
I think this is very simple script, but I can't make it.
I made a script to add bodies on Product, not open the window a part.
Of course, I can make it with the selection.
But I don't know how to add bodies without the selection on the Product.
Could you check below my scripts?
The first script is with the Selection, the second script is without the selection.
CODE --> VBScript
Sub CATMain() Set Selection1 = CATIA.ActiveDocument.Selection Set Selection2 = Selection1.Item(1).Value Set partDocument1 = CATIA.Documents.Item(Selection2.Name+".CATPart") Set part1 = partDocument1.Part Set bodies1 = part1.Bodies Set body1 = bodies1.Add() part1.Update End Sub
CODE --> VBScript
Sub CATMain() Set partDocument1 = CATIA.Documents.Item(1) Set part1 = partDocument1.Part Set bodies1 = part1.Bodies Set body1 = bodies1.Add() part1.Update End Sub





RE: (VBScript) Without the Selection, How to Add Bodies on the Product?
Are you wroking in a CATPart in an active window or in a Product?
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: (VBScript) Without the Selection, How to Add Bodies on the Product?
RE: (VBScript) Without the Selection, How to Add Bodies on the Product?
You need to identify somehow the target where to create the bodies, otherwise how can your macro know where to add the new features ?
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: (VBScript) Without the Selection, How to Add Bodies on the Product?
Yes, I know what you mean..
But I thought the new way to do it..
RE: (VBScript) Without the Selection, How to Add Bodies on the Product?
If the first item in the product is a part, you could set the part like this:
Set product1 =Catia.activedocument.product
set part1 = product1.products.item(1).parent.part
Item(1) is the instance level of the first part
.parent is the document of the first part
.part is the part
RE: (VBScript) Without the Selection, How to Add Bodies on the Product?
Thank you for your reply.
I tried with your code.
But it doesn't work.
Can you check my code?
CODE --> VBScript