How to create a formula with a script, in CATPart, with a link to an external parameter.

fedor biryukov

How to create a formula with a script, in CATPart, with a link to an external parameter.

Good day to all. in Part, I create a formula and refer to an external parameter, such as a parameter in a skeleton. The Exerternal Parameters structure appears in the active part, and the formula already refers to a parameter in this structure, as if to a local one. Is it possible to create such a structure with a script.

Thank you in advance for your response

Little Cthulhu

RE: How to create a formula with a script, in CATPart, with a link to an external parameter.
(in response to fedor biryukov)

Not possible.

Cliff Johnson, Cliff

RE: How to create a formula with a script, in CATPart, with a link to an external parameter.
(in response to fedor biryukov)

You can perform a copy-paste-with-link of the parameter then create a formula. It is easiest if the parameter is published in the source part. 

Something like this:

Sub Main()
Dim oRootDoc As ProductDocument
Set oRootDoc = CATIA.ActiveDocument

Dim oPFrom As Product
Set oPFrom = oRootDoc.Product.Products.Item("Part1.1")

Dim oPTo As Product
Set oPTo = oRootDoc.Product.Products.Item("Part4.1")

Dim oSel As Selection
Set oSel = oRootDoc.Selection

Call oSel.Clear
Call oSel.Add(oPFrom.Publications.Item("SomeLength").Valuation)

Call oSel.Copy
Call oSel.Clear

Dim oPart As Part
Set oPart = oPTo.ReferenceProduct.Parent.Part
Call oSel.Add(oPart)
Call oSel.PasteSpecial("CATPrtResult")

Call oSel.Clear

Dim oExternalParam As Parameter
Set oExternalParam = oPart.Parameters.Item("SomeLength")

Dim oFXOutParam As Parameter
Set oFXOutParam = oPart.Parameters.Item("Length.1")

Dim oFXFactorParam As Parameter
Set oFXFactorParam = oPart.Parameters.Item("Real.1")

Dim oFX A s Formula
Set oFX = oPart.Relations.CreateFormula("FX", "", oFXOutParam, oPart.Parameters.GetNameToUseInRelation(oExternalParam) & " * " & oPart.Parameters.GetNameToUseInRelation(oFXFactorParam))

oPart.Update

End Sub


Even easier is to use a power copy and not bother with a script 

 

 

 

How to ask questions 

Attachments

  • powercopy.jpg (86.1k)