evereux / pycatia

python module for CATIA V5 automation
MIT License
196 stars 53 forks source link

[BUG] [add_new_extrapol_length] TypeError on setting support #211

Closed HyberCa closed 5 months ago

HyberCa commented 5 months ago

Describe the bug When I try to extend a line using the add_new_extrapol_length method and set the support surface using the support attribute, the compiler suggests that there is a type error.

To Reproduce A active part in Generative Shape Design A surface named Surface1 A line named Xa Spline A point in Xa Spline named Point.1

import pycatia
from pycatia.mec_mod_interfaces.part import Part
from pycatia.mec_mod_interfaces.part_document import PartDocument
from pycatia.in_interfaces.reference import Reference

caa = pycatia.catia()
CurDoc = PartDocument(caa.active_document.com_object)
CurPart = Part(CurDoc.part.com_object)

HSF = CurPart.hybrid_shape_factory
inputGeo = CurPart.hybrid_bodies.item("InputGeo")
XLineLeftPointRef = Reference(inputGeo.hybrid_shapes.item("Point.1").com_object)
XaLineRef = Reference(inputGeo.hybrid_shapes.item("Xa Spline").com_object)
XLeftExtend = HSF.add_new_extrapol_length(XLineLeftPointRef, XaLineRef, 10)
Surface1Ref = Reference(inputGeo.hybrid_shapes.item("Surface1").com_object)
XLeftExtend.support = Surface1Ref
inputGeo.append_hybrid_shape(XLeftExtend)
CurPart.in_work_object = XLeftExtend
CurPart.update()

and traceback is :

Traceback (most recent call last):
  File "e:\bugReport.py", line 18, in <module>
    XLeftExtend.support = Surface1Ref
  File "D:\------\envs\pycatiaEnv\lib\site-packages\pycatia\hybrid_shape_interfaces\hybrid_shape_extrapol.py", line 375, in support
    self.hybrid_shape_extrapol.Support = value
  File "D:\------\envs\pycatiaEnv\lib\site-packages\win32com\client\dynamic.py", line 685, in __setattr__
    self._oleobj_.Invoke(entry.dispid, 0, invoke_type, 0, value)
TypeError: must be real number, not Reference

Expected behavior LineExtend.support should use a refrence to set a set a support surface to add_new_extrapol_length.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context I think this issue is very similar to #141. I tried to change pycatia\hybrid_shape_interfaces\hybrid_shape_extrapol.py line 375 from

self.hybrid_shape_extrapol.Support = value

to

self.hybrid_shape_extrapol.Support = value.com_object

This successfully avoids the TypeError and work well.

evereux commented 5 months ago

This has been now been fixed in 0.6.9. I found another instance of the same issue which was also fixed.

Thanks for your report! 👍