-
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
[FEATURE REQUEST] Implementation of add_new_translate operation #202
Comments
Should that be It looks like this is another undocumented feature (no mention of it in chm help file) so wasn't implemented. For reference here are the details from the VB Object browser (should someone wish to add before I do):
|
It seems that |
It should be straightforward to do. 😊 |
Turns out it wasn't so straight forward! I've added the feature in the development branch. I had a hard time figuring out why I couldn't get it to work in a way I expected and I'm still confused why I have to write this example this way: from pycatia import catia
from pycatia.hybrid_shape_interfaces.hybrid_shape_translate import HybridShapeTranslate
from pycatia.in_interfaces.reference import Reference
from pycatia.mec_mod_interfaces.hybrid_shape import HybridShape
from pycatia.mec_mod_interfaces.part_document import PartDocument
caa = catia()
part_document = PartDocument(caa.active_document.com_object)
part = part_document.part
bodies = part.bodies
part_body = bodies.item('PartBody')
part.in_work_object = part_body
hybrid_shape_factory = part.hybrid_shape_factory
origin_elements = part.origin_elements
xy_plane = origin_elements.plane_xy
ref_xy_plane = part.create_reference_from_object(xy_plane)
direction = hybrid_shape_factory.add_new_direction(ref_xy_plane)
shape_factory = part.shape_factory
translate = shape_factory.add_new_translate2(100)
hybrid_shape_translate = HybridShapeTranslate(translate.com_object.HybridShape)
hybrid_shape_translate.vector_type = 0
hybrid_shape_translate.direction = direction
part.update() The quirk being this line
I couldn't successfully define the edit: see my reply for an more correct script example. |
add_new_translate2 returns a Translate object. So I am guessing its intended to access the HybridShapeTranslate like that. Do you know how the Translate class is used in another context? Or is it only used in the context of using its .HybridShape method? |
Where did you get that information? All I've got is what I posted above. I've seen the Translate object and I did try initializing that using the AnyObject returned from I'll do some more experimenting.
Not a clue how the Translate class is used in any other context. |
I can see from the generated macro that this is produced:
Which I've tried to reproduce. |
I've updated This is what I expected to be able to do:
You can see there's an issue by trying to |
I'm currently out of ideas for this so I'm going to release 0.6.7 today. I'll keep this issue open in the hope that we can somehow improve |
Hi again! Thanks for updating the pycatia version, now I can use the I am using the following code:
How could I apply this operation correctly? Thank you in advance! P.S. Your "unconventional" way to proceed works for me :
|
Did you try recording a macro to see how it's implemented there? It's pretty much always going to be my first question. It's a very helpful tool to help point us in the right direction. I think not since |
I tried to record the operation in the CATIA macro recorder and the code was something like this:
Which is the same that I tried to do but with the corresponding pycatia syntax. It seems to fail when passing the hybrid direction that I created using
|
That vector type is definitely wrong if you're trying to translate by co-ordinates. See the documentation I linked to (open the Note).
Can you post the output of the macro you created please? |
But that's not what you want. |
Can you clarify here what it is you actually want to do? Reading over these posts again I'm now not sure if you want to translate in a specific direction or translate by co-ordinates? You seem to be mixing two concepts up here? Anyway, if you can post the full output of a macro recording what you're trying to do that would be helpful. |
Just wanted to add an updated example which is now technically correct: from pycatia import catia
from pycatia.hybrid_shape_interfaces.hybrid_shape_translate import HybridShapeTranslate
from pycatia.mec_mod_interfaces.part_document import PartDocument
caa = catia()
part_document = PartDocument(caa.active_document.com_object)
part = part_document.part
bodies = part.bodies
part_body = bodies.item('PartBody')
part.in_work_object = part_body
hybrid_shape_factory = part.hybrid_shape_factory
origin_elements = part.origin_elements
xy_plane = origin_elements.plane_xy
ref_xy_plane = part.create_reference_from_object(xy_plane)
direction = hybrid_shape_factory.add_new_direction(ref_xy_plane)
shape_factory = part.shape_factory
translate = shape_factory.add_new_translate2(100)
hybrid_shape_translate = HybridShapeTranslate(translate.hybrid_shape.com_object)
hybrid_shape_translate.vector_type = 0
hybrid_shape_translate.direction = direction
part.update() What I've done here is change |
I'm closing this now as the original issues are resolved. |
Dear support,
I have noticed that the
add_new_translate
body operation is missing in shape_factory. This body operation simply translates the part in a desired direction for an specified distance. Would it be possible to include this operation for future versions of pycatia?Kind regards,
César.
The text was updated successfully, but these errors were encountered: