I'm trying to do some design automation in CATIA. I'm using python, I then record macros in CATIA and translates the code there to python code. Now I have stumbled upon a problem.
Below is the Macro from CATIA that i want to translate into pyhton code.
Language="VBSCRIPT"
Sub CATMain()
Set productDocument1 = CATIA.ActiveDocument
Set product1 = productDocument1.Product
Set product1 = product1.ReferenceProduct
Set constraints1 = product1.Connections("CATIAConstraints")
Set reference1 = product1.CreateReferenceFromName("ContainerSchiff/Container1/!yz plane")
Set reference2 = product1.CreateReferenceFromName("ContainerSchiff/Container0/!Geometrical Set.1/Point.2")
----Here is the problem ---- Set constraint1 = constraints1.AddBiEltCst(catCstTypeDistance, reference1, reference2)
Set length1 = constraint1.Dimension
length1.Value = 300.000000
product1.Update
End Sub
When translating this i have no idea what to do with catCstTypeDistance
If I leave it as is, then python will obviously complain about the name not being defined. If I pass it as a string complains as well. Below is the part of the python
else:
add_container_skeleton(product1,i)
product1.ReferenceProduct
constraints1=product1.Connections("CATIAConstraints")
Name1="ContainerSchiff/Container" + str(i-1) + "/!Container1/yz plane"
Name2="ContainerSchiff/Container" + str(i) + "/!Geometrical Set.1/Point.2"
reference1= product1.CreateReferenceFromName(Name1)
reference2 = product1.CreateReferenceFromName(Name2)
constraint1 = constraints1.AddBiEltCst('catCstTypeDistance', reference1, reference2)
length1 = constraint1.Dimension
length1.Value = 300.000000
and the two different error messages that I get.
File "C:\Users\Mange\Documents\LIU\Catia part 2\first_draft.py", line 179, in place_containers
constraint1 = constraints1.AddBiEltCst('catCstTypeDistance', reference1, reference2)
File "<COMObject Connections>", line 3, in AddBiEltCst
ValueError: invalid literal for int() with base 10: 'catCstTypeDistance'
File "C:\Users\Mange\Documents\LIU\Catia part 2\first_draft.py", line 179, in place_containers
constraint1 = constraints1.AddBiEltCst(catCstTypeDistance(), reference1, reference2)
NameError: name 'catCstTypeDistance' is not defined
How can I "access" this thing/object(?) from python?