-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FTA_NonSemanticGDT has no usable properties & FTA_NonSemanticDimension.has_dimension #236
Comments
It's probably deeper than mine. :-) There are some features of this module I can't test as they were introduced in a later CATIA version than I'm able to test with right now. So, bare with me here ... :-) The docs state for Annotations.item2: | o Func Item2(CATVariant iIndex) As AnyObject It states that it returns an AnyObject in the first line but it should actually return a If I make this change to the development branch so that it does this are you able to test it? The Annotations.item2() class method just fails for me due most likely to a CATIA version issue.
I can't reproduce this issue. See example below. Take a look at the following code sample with regards for checking types and then initialising them. from pycatia import catia
from pycatia.mec_mod_interfaces.part_document import PartDocument
from pycatia.cat_tps_interfaces.non_semantic_gdt import NonSemanticGDT
from pycatia.cat_tps_interfaces.non_semantic_dimension import NonSemanticDimension
caa = catia()
appliation = caa.application
part_document: PartDocument = appliation.active_document
part = part_document.part
annotation_sets = part.annotation_sets
annotation_set_1 = annotation_sets[0]
annotations = annotation_set_1.annotations
fta_simple_datums = []
fta_non_semantic_gdts = []
fta_non_sematic_dimensions = []
for annotation in annotations:
# the annotation collection object doesn't assign annotation type to items.
# so type needs to be checked and type created manually to work with it.
print(annotation.type)
if annotation.has_dimension_limit():
print(annotation.dimension_limit())
if annotation.type == 'FTA_DatumSimple':
fta_ds = annotation.datum_simple()
fta_simple_datums.append(fta_ds)
if annotation.type == 'FTA_NonSemanticGDT':
fta_ns_gdt = NonSemanticGDT(annotation.com_object)
fta_non_semantic_gdts.append(fta_ns_gdt)
if annotation.type == 'FTA_NonSemanticDimension':
fta_ns_dim = NonSemanticDimension(annotation.com_object)
fta_non_sematic_dimensions.append(fta_ns_dim)
# check functionality of annotations
for fta_simple_datum in fta_simple_datums:
print('__ fta simple datum __')
print(fta_simple_datum)
print(fta_simple_datum.label)
print(fta_simple_datum.targets)
for fta_non_semantic_gdt in fta_non_semantic_gdts:
print('__ fta non semantic gdt __')
print(fta_non_semantic_gdt)
print(fta_non_semantic_gdt.get_2d_annot())
print(fta_non_semantic_gdt.tps_parallel_on_screen())
for fta_non_sematic_dimension in fta_non_sematic_dimensions:
print('__ fta non semantic dimension __')
print(fta_non_sematic_dimension)
print(fta_non_sematic_dimension.dimension_limit())
print(fta_non_sematic_dimension.get_2d_annot())
print(fta_non_sematic_dimension.has_dimension_limit()) |
Thank you for taking the time to help me. Of course I am able to test it, I can test upto R32. I tried it myself by changing the AnyObject to an Annotation2 object but importing the Annotation2 resulted in an error about some kind of import loop, which I could not unravel. I tested your code in R30 and R32.
The functions attached to the fta_non_semantic_gdt objects both fail:
I am not sure if the get_2d_annot function is capable to show a 3d FTA tolerance as 2d, or if it only works if it comes from the drafting workbench. Altough I would expect the variables to be the same. The V5 automation book is quite empty with respect to this class :). |
For a quick fix for the import loop problem, which may end up being permanent, try doing the import within the class method itself and not at the top of the file. There are a number of places where I could see no option but do this for this project. So you would have something like: def item2(self, i_index: cat_variant) -> 'Annotation2':
"""
.. note::
:class: toggle
CAA V5 Visual Basic Help (2020-09-25 14:34:21.593357))
| o Func Item2(CATVariant iIndex) As AnyObject
|
| Retrieve an Annotation using interface CATIAAnnotation2
:param cat_variant i_index:
:rtype: Annotation2
"""
from pycatia.cat_tps_interfaces.annotation_2 import Annotation2
return Annotation2(self.annotations.Item2(i_index)) I'll have another look at these issues over the weekend and see if there's something silly I've done that's an easy fix. |
Just edited post to correct the return statement. 🙁 |
I've pushed the above change to the development branch. I've also added a number of version checks which won't be interesting for you. Ultimately though almost all of this I'm unable to test and I can't see any obvious errors I may have made.
I don't understand what you're saying here. If the annotation doesn't have a dimension limit, it won't be printed. if annotation.has_dimension_limit():
print(annotation.dimension_limit())
Hmm, you might be right here. NonSemanticGDT.get_2d_annot() returns a DrawingGDT object which The only way to know for sure I guess is to write something quick and dirty in VBA/CATScript. 🤢 |
I tested the updated code. I do not get any strange errors from the test script or see any strange classes popping up anymore.
It should not, but in this case it thinks there is no dimension_limits, while there actually is. if annotation.type == 'FTA_NonSemanticDimension':
print('__ fta non semantic dimension test __')
fta_ns_dim = NonSemanticDimension(annotation.com_object)
fta_non_sematic_dimensions.append(fta_ns_dim)
print(annotation.has_dimension_limit())
print(annotation.dimension_limit().nominal_value)
print(fta_ns_dim.dimension_limit())
print('-------------------------------------') Returns:
So the .has_dimension_limit() returns False, but if I am stubborn I do get the values. I also tried running the original script you send, it results in both errors for both the 2D annotation:
TPS:
Or does the tps view of a tolerance needs to be converted to an object on a drawing view to get the information out of the tolerance? I am scouring the VBA fora but it only found related questions and no answers. I just found an article that might lead to getting the tolerance id via the annotations class and then using the methods for tps views, but I think that it is a long shot. |
The inconsistent behaviour of Until I can get access to a fairly recent version of CATIA V5 for testing there's not much more I can do. Unfortunately, I can't see that happening for several months at the moment. |
I am trying to capture all requirements from a Catia V5 Part for a work related project. All tolerances are set in 3D using the FTA module. Sadly some are not directly connected to features (NonSemantic). I can access most type however for the FTA_NonSemantic* types I have some problems. I'm a bit lost and can not find any examples that try the same. Can someone tell me if this is a bug or that I am doing something wrong?
Description
I have problems with three distinct classes, I think I am not getting the right Annotation class, but my understanding of package does not go that deep:
FTA_NonSemanticDimension
A dimension with the type FTA_NonSemanticDimension returns a DimensionLimit object while the .has_dimension_limit() returns false. I am not sure if this is a bug or that I am using the wrong interface.
FTA_NonSemanticGDT & FTA_NonSemanticTarget
I cannot get the annotation object to return anything. None of the functions in pycatia/cat_tps_interfaces_annotation returns a result. They all give the same generic error.
I noticed that in pycatia/cat_tps_interfaces_annotations it states that Annotation.item()(CATIAAnnotation interface) is deprecated and that item2 (CATIAAnnotation2 interface) should be used. If I manually try that using 'annotations.item2(x)' I get an AnyObject, which is not the expected Annotation2 object. It does seem that Annotation2 has functions related to the FTA_NonSemanticDimension types.
To Reproduce
FTA_NonSemanticDimension
A dimension with the type FTA_NonSemanticDimension returns a DimensionLimit object while the Annotation.has_dimension_limit() function returns False.
FTA_NonSemanticGDT
The generic error is:
Screenshots

Below is a generic picture a found that looks very much like the 3D non semantic tolerance but in 2D instead of 3D.
Desktop (please complete the following information):
Additional context
I can not attach the CATParts as they are work related, sorry.
The text was updated successfully, but these errors were encountered: