Git Product home page Git Product logo

Comments (11)

evereux avatar evereux commented on August 23, 2024

Just cloned the repo and run the tests. That test does not fail here.

from pycatia.

Zhigang-shrek avatar Zhigang-shrek commented on August 23, 2024

You mean the last method in your test file?
Thank you!

from pycatia.

evereux avatar evereux commented on August 23, 2024

I think you're talking about this

def test_get_center():

This isn't the last test and while I commented in the code that it failed all the tests do pass (this test is commented out). I wrote these tests sometime ago so I'd forgotten about it and your posts confused me.

I'll have a look at this and see if i can solve it.

from pycatia.

Zhigang-shrek avatar Zhigang-shrek commented on August 23, 2024

I'm really talking about this. I set part_body as reference but couldn't get the center.
I don't know whether it's my own problem or any other problem or not. After seeing the post, I found that you also encountered this problem, so I came to ask you.
Thanks again!

from pycatia.

evereux avatar evereux commented on August 23, 2024

This works for me.

from pycatia import CATIADocHandler
from pycatia import CATIAMeasurable
from pycatia import create_measurable
from pycatia import create_spa_workbench

measurable_part = 'tests\\CF_catia_measurable_part.CATPart'



with CATIADocHandler(measurable_part) as handler:
    catia = handler.catia
    document = handler.document

    center = (-47.039, 83.488, 0.0)

    spa_workbench = create_spa_workbench(document.document)
    part = document.part()

    body = part.get_body_by_name('PartBody')

    body_reference = part.create_reference(body)
    body_measurable = create_measurable(spa_workbench, body_reference)

    catia_measurable_body = CATIAMeasurable(body_measurable)
    catia_center = catia_measurable_body.get_cog(catia)

    print(catia_center)

from pycatia.

Zhigang-shrek avatar Zhigang-shrek commented on August 23, 2024

Does this method not apply in the products documentation?
For example, I want to get the center of gravity coordinates of a part in products.

from pycatia.

Zhigang-shrek avatar Zhigang-shrek commented on August 23, 2024

I want to get the center of gravity coordinates of each part in an assembly, and judge the relationship between each part through some algorithms. And I'm sorry that I didn't tell you that I used Visual Basic 6.0 to do CATIA development. Thank you for your reply. You don't need to help me. Let me find a way for myself. If I solve it, I'll let you know at the first time.

from pycatia.

evereux avatar evereux commented on August 23, 2024

I've just pushed some updates to the Master branch that'll help you do what I think you want.

Take a look at example_10.py.

from pycatia.

Zhigang-shrek avatar Zhigang-shrek commented on August 23, 2024

I think I still need your help. This is my code written in VB:
Dim part1
Set part1 = selection1.Item(1).Value
Dim ref1 As Reference
Set ref1 = part1.CreateReferenceFromObject(part1.MainBody)
Dim TheSPAWorkbench As Workbench
Set TheSPAWorkbench = CATIA.ActiveDocument.GetWorkbench("SPAWorkbench")
Dim TheMeasurable As Object
Set TheMeasurable = TheSPAWorkbench.GetMeasurable(ref1)
Dim VOL
VOL = TheMeasurable.Volume 'Return the volume of part1
Dim coords(2)
TheMeasurable.GetCOG (coords)
Dim x1, y1, z1
x1 = coords(0)
y1 = coords(1)
z1 = coords(2)

Part1 is a part body, I can get the volume of part1 in this way. But I use GetCOG to get the center of gravity coordinates and return null values. I don't know where the problem is.

from pycatia.

evereux avatar evereux commented on August 23, 2024

Where is your python code? VB code is no help to me.

from pycatia.

evereux avatar evereux commented on August 23, 2024

I'm closing this as it doesn't seem to be related to pycatia.

from pycatia.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.