VB scripting - how to address a Product?
VB scripting - how to address a Product?
(OP)
I am trying to get a script to run within the context of an assembly, I can't seem to get the "Product related" lines correct. Any Ideas?
My Script does work when only running in a Catpart...
*********** I'm adding this part (doesn't work)
'find product information
Dim product1 As product
Set product1 = CATIA.Activeproduct
Set product1 = partdocument
*********** For here down works (in a .CatPart)
'set current catia document as current
Dim partDocument1 As partDocument
Set partDocument1 = CATIA.ActiveDocument
Dim ActivePart As Part
Set ActivePart = partDocument.Part
Dim parameters1 As parameters
Set parameters1 = ActivePart.parameters
......etc.....
Any Ideas?
Thanks,
- BsurfN99
My Script does work when only running in a Catpart...
*********** I'm adding this part (doesn't work)
'find product information
Dim product1 As product
Set product1 = CATIA.Activeproduct
Set product1 = partdocument
*********** For here down works (in a .CatPart)
'set current catia document as current
Dim partDocument1 As partDocument
Set partDocument1 = CATIA.ActiveDocument
Dim ActivePart As Part
Set ActivePart = partDocument.Part
Dim parameters1 As parameters
Set parameters1 = ActivePart.parameters
......etc.....
Any Ideas?
Thanks,
- BsurfN99





RE: VB scripting - how to address a Product?
' Initialise Part Settings
Dim CurrentDoc As Document
Set CurrentDoc = CATIA.ActiveDocument
Dim CurrentProd As Product
Set CurrentProd = CurrentDoc.Product
It works ok on the macro I'm working on, which follows a similar strategy to the one you describe
If Beethoven had been killed in a plane crash at the age of 22, it would have changed the history of music...
and of aviation.
RE: VB scripting - how to address a Product?
'find product and part information
Dim CurrentDoc As document
Set CurrentDoc = CATIA.ActiveDocument
Dim CurrentProd As product
Set CurrentProd = CurrentDoc.product
Dim parameters1 As parameters
Set parameters1 = CurrentDoc.parameters ***
I'm sure I'm missing something basic here, any ideas?
BsurfN99
RE: VB scripting - how to address a Product?
If Beethoven had been killed in a plane crash at the age of 22, it would have changed the history of music...
and of aviation.
RE: VB scripting - how to address a Product?
Thanks for your help...
-BsurfN99
RE: VB scripting - how to address a Product?
Dim productDocument1 As ProductDocument
Set productDocument1 = CATIA.ActiveDocument
Dim Rootprod As Product
Set Rootprod = productDocument1.Product
Dim MyProd As product
Set MyProd = Rootprod.products.Item("iproduct.name")
Dim Parameters1 As Parameters
Set Parameters1 = MyProd.Parameters
i = 0
do
i = i + 1
Msgbox Parameters1.item(i).Name
loop until i = Prameters1.Count
Hope this would work for you
RE: VB scripting - how to address a Product?
Here is what I am tring do accomplish.
Within any CatPart, wheather I have open just a CatPart or if I am active in a Catpart, within a product; I have set parameters that I may want to apply to my CatPart.
At the moment, I have this working only for working only in a Catpart, It errors out if I try to run it when working in a Catpart that is also in a CatProduct. I would like to fix this. I am fairly new to VBA, any help is much appreciated.
Thanks for everyones help...
-BsurfN99
"The secret to success is the consistency to pursue."
- Harry F. Banks
RE: VB scripting - how to address a Product?