-
Notifications
You must be signed in to change notification settings - Fork 53
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
Obtain Bounding Box from components in a Product #10
Comments
Hi,
I know exactly what you're talking about but haven't looked at automating
this. The problem I see is that the bounding box can differ whether the
root is selected or individual body/bodies. Making it select the root in
all cases is potentially dangerous.
It's certainly possible I think but off the top of my head I can't think of
a nice fool proof way to implement ... unless the automation fires off many
warnings.
Paul
…On Wed, Nov 13, 2019 at 4:29 PM mrjapon ***@***.***> wrote:
Hello,
I'm trying to obtain the Bounding Box of several ítems in a Product. The
Bounding Box is available once is launched the 'Measure Inertia' inside
CATIA, and clicking on Principal Axis in Customize options (see
https://www.cadcam-group.eu/catia-v5-bounding-box). Once you have done
this, it is easy to recover these parameters from the CATIA tree.
The problem is that I cannot automatize 'Measure Inertia', that is what
measures and save the parameters in the tree.
I've seen you have some examples that obtain the CoG, mass, and some other
parameters. Is it posible to do so to get these three parameter of the
Bounding Box?
Thank you
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#10?email_source=notifications&email_token=AEXQWRCRBU2OQ6LPA6EGTETQTQTPRA5CNFSM4JM56ZEKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HZCFSHA>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEXQWRCHTWATMPP2TV7KVI3QTQTPRANCNFSM4JM56ZEA>
.
|
Thk for your answer. In fact, I was thinking about the bounding box (and
cog) of subproducts inside a product, so that problem would not exist,
since each root-subproduct is the item to measure
…On Wed, Nov 13, 2019, 20:52 evereux ***@***.***> wrote:
Hi,
I know exactly what you're talking about but haven't looked at automating
this. The problem I see is that the bounding box can differ whether the
root is selected or individual body/bodies. Making it select the root in
all cases is potentially dangerous.
It's certainly possible I think but off the top of my head I can't think of
a nice fool proof way to implement ... unless the automation fires off many
warnings.
Paul
On Wed, Nov 13, 2019 at 4:29 PM mrjapon ***@***.***> wrote:
> Hello,
> I'm trying to obtain the Bounding Box of several ítems in a Product. The
> Bounding Box is available once is launched the 'Measure Inertia' inside
> CATIA, and clicking on Principal Axis in Customize options (see
> https://www.cadcam-group.eu/catia-v5-bounding-box). Once you have done
> this, it is easy to recover these parameters from the CATIA tree.
> The problem is that I cannot automatize 'Measure Inertia', that is what
> measures and save the parameters in the tree.
> I've seen you have some examples that obtain the CoG, mass, and some
other
> parameters. Is it posible to do so to get these three parameter of the
> Bounding Box?
> Thank you
>
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> <
#10?email_source=notifications&email_token=AEXQWRCRBU2OQ6LPA6EGTETQTQTPRA5CNFSM4JM56ZEKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HZCFSHA
>,
> or unsubscribe
> <
https://github.com/notifications/unsubscribe-auth/AEXQWRCHTWATMPP2TV7KVI3QTQTPRANCNFSM4JM56ZEA
>
> .
>
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#10?email_source=notifications&email_token=AEVQJLVNTEANQOE4J2FUTJTQTRLIXA5CNFSM4JM56ZEKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOED7NY5Q#issuecomment-553573494>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEVQJLVUAO3ORW7IHOWRDDDQTRLIXANCNFSM4JM56ZEA>
.
|
Aah ok got you. I've never used the feature like that. Let me have a look at the automation API and see if I can come up with something. Might be a few days but I'll definitely respond. |
This macro (in VB) can help for sure. I'm studying and translating it to Python. Let's see.... |
Sorry I've not responded sooner. I've looked at the VB script and whilst it's certainly doable in python it's not something I currently have time to look at in detail sorry. Maybe in the near future. |
How to get the user defined properties in part or product? i am trying with "user_ref_properties", its throwing me a com error like below. com_error: (-2147352567, 'Exception occurred.', (0, 'CATIAProduct', 'The method UserRefProperties failed', None, 0, -2147467259), None) Can any one help me in that? |
@tcrakshi This is unrelated to the original post. A new issue has been raised. I will reply to the issue there. |
@mrjapon I see you faced this issue some time back. Were you able to make any progress on this? |
Sorry, I left this issue stopped. One day I'll take it back and find the
code for it. Good luck!!
El lun., 7 sept. 2020 a las 22:08, Manjit Kumar (<notifications@github.com>)
escribió:
… @mrjapon <https://github.com/mrjapon> I see you faced this issue some
time back. Were you able to make any progress on this?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#10 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEVQJLS5ZW5BG34QREGJKHLSEU4VFANCNFSM4JM56ZEA>
.
|
Hi,
The |
Try this: from pycatia import catia
caa = catia()
document = caa.active_document
product = document.product()
spa_workbench = document.spa_workbench()
inertias = spa_workbench.inertias
# clear existing inertias.
# this is required since the CAA object seems to keep the inertia collection in
# memory on each iteration of the script. Not sure if this is by design or
# something pycatia should be doing.
for i in range(inertias.count):
inertias.remove(1)
# add product to inertia collection.
inertias.add(product)
for inertia in inertias:
print(inertia.mass)
print(inertia.get_cog_position())``` |
Good luck! I've been trying to solve this and can't figure out the problem. |
Aha, that's the correct solution to get a exact Inertia instance. But it's pity I didn't find the bound box parameters directly. I tried another solution, simply and directly translated from
Here is one more issue should we pay attention, as CAA Document describe StartCommand:
I think "Measure Inertia" is not one-shot command. To solve this, it would be anther issue #39. @mrjapon, please check whether it is you mean. |
If I understand correct and you want the script to stop and wait for input from a user could you use a messagebox to prompt the user? Hopefully I'll provide an example script tomorrow. 🤷♂️ |
This is actually more complex than I thought to make it interactive, for a number of reasons:
This is going to need some more thought. |
I've tried |
This seems to work but comes with a warning. Please test thoroughly. """
Example 26:
Prompt the user to select a product and get it's bounding box parameters
.. warning:
Currently there must be NO other existing Measure Inertias saved
ANYWHERE in your product tree as these may be returned and not
product you have selected.
"""
import win32con
import win32gui
from pycatia import catia
def close_inertia_window():
# for future debugging from https://stackoverflow.com/questions/55547940/how-to-get-a-list-of-the-name-of-every-open-window
# def winEnumHandler(hwnd, ctx):
# if win32gui.IsWindowVisible(hwnd):
# print(hex(hwnd), win32gui.GetWindowText(hwnd))
#
# win32gui.EnumWindows(winEnumHandler, None)
handle = win32gui.FindWindow(None, "Measure Inertia")
win32gui.PostMessage(handle, win32con.WM_CLOSE, 0, 0)
caa = catia()
document = caa.active_document
product = document.product()
selection = document.selection
selection.clear()
c = True
while c is True:
input("Selection product to measure.\nPress <ENTER> when selection made.")
selection = document.selection
caa.start_command("Measure Inertia")
parameters = product.parameters
print(f"BBOx = {parameters.item('BBOx').value_as_string()}.")
print(f"BBOy = {parameters.item('BBOy').value_as_string()}.")
print(f"BBOz = {parameters.item('BBOz').value_as_string()}.")
print(f"BBLx = {parameters.item('BBLx').value_as_string()}.")
print(f"BBLy = {parameters.item('BBLy').value_as_string()}.")
print(f"BBLz = {parameters.item('BBLz').value_as_string()}.")
selection.clear()
close_inertia_window()
prompt = input("Continue? (Y/N):")
if prompt.lower()[0] == 'n':
c = False
else:
c = True |
👍 Brilliant! |
It's really good example everex, def close_inertia_window(), this function is closing command dialog box, If it possible , thee we can address most of the issue, like generate catpart,. , Etc |
It's possible. |
See example 20. message_box does what I think you're asking. |
Closing this as issue as I think it's resolved to a degree although the solution isn't perfect yet. |
Hello,
I'm trying to obtain the Bounding Box of several ítems in a Product. The Bounding Box is available once is launched the 'Measure Inertia' inside CATIA, and clicking on Principal Axis in Customize options (see https://www.cadcam-group.eu/catia-v5-bounding-box). Once you have done this, it is easy to recover these parameters from the CATIA tree.
The problem is that I cannot automatize 'Measure Inertia', that is what measures and save the parameters in the tree.
I've seen you have some examples that obtain the CoG, mass, and some other parameters. Is it posible to do so to get these three parameter of the Bounding Box?
Thank you
The text was updated successfully, but these errors were encountered: