icon

[Otázka] Gravity Center [Vyřešeno]

Tagy:
  • Allplan
  • 2025
  • Visual
  • Scripting
  • Bug
  • Issue
  • Code
  • 3dmodel

Hello there,

I've made a visual script to try and get the gravity center but get error every time (cf pictures) and i don't know what to do to resolve the issue. If you have any idea i take it !

Thanks for answering

Přílohy (3)

Type: image/png
Staženo 48
Size: 66,33 KiB
Type: image/png
Staženo 37
Size: 64,27 KiB
Type: image/png
Staženo 27
Size: 57,86 KiB

Show solution Hide solution

Hi

Here a starting point for your script (ALLPLAN 2025)

The idea is to select by mouse the objects, then I made a filter based on the geometry (I made it in Python, maybe can be done with nodes....)

import NemAll_Python_Geometry as Geometry

def function_to_execute(ele_list) -> list[Geometry.Polyhedron3D]:
    """ implement the script code here """
    polyh_list = []
    for ele in ele_list:
        if isinstance(ele, Geometry.Polyhedron3D):
            polyh_list.append(ele)
    return polyh_list

Then Union and finally CalculateMass

Christophe

Přílohy (2)

Type: application/x-sqlite3
Staženo 43
Size: 132,00 KiB
Type: image/png
Staženo 33
Size: 62,42 KiB

The CalcMass-Node and also the underlaying function accepts only 3D-Solids, like Polyhedron3D, BRep3D and others shown in the message. You have obviously select a 2D-Line!
If you want the Centerpoint of the line, please use other Node to get it!

I need to find the gravity center of this 3D model what node should I use to get CalcMass to function correctly ?

Přílohy (1)

Type: image/png
Staženo 36
Size: 10,39 KiB

Maybe filter the Elements with Geometry of Polyhedron3D or BRep3D first!

If I may ask: What is the point of gravity needed for?

Doesn't the center of the bounding box do the same thing?

I did try with bounding box but got the exact same problems.

I tried something else but i think i miss something (Cf video)

Přílohy (1)

Type: application/x-7z-compressed
Staženo 48
Size: 3,84 MiB

Hi,

Here an example

1) you select the objects
2) the script make an union of the objects
3) then it calculates the gravity point

Best
Christophe

Přílohy (1)

Type: image/png
Staženo 30
Size: 62,84 KiB

I copy what you did but i get : "Union: Attemting to append an invalid type"

Is it because I selected multiple objects or not ?

I tried with some 3D objects, but not with arch elements.

Can you post your drawing file with your objects?

I hope this is helpful

Přílohy (1)

Type: application/zip
Staženo 47
Size: 1,80 MiB

Hi

Here a starting point for your script (ALLPLAN 2025)

The idea is to select by mouse the objects, then I made a filter based on the geometry (I made it in Python, maybe can be done with nodes....)

import NemAll_Python_Geometry as Geometry

def function_to_execute(ele_list) -> list[Geometry.Polyhedron3D]:
    """ implement the script code here """
    polyh_list = []
    for ele in ele_list:
        if isinstance(ele, Geometry.Polyhedron3D):
            polyh_list.append(ele)
    return polyh_list

Then Union and finally CalculateMass

Christophe

Přílohy (2)

Type: application/x-sqlite3
Staženo 43
Size: 132,00 KiB
Type: image/png
Staženo 33
Size: 62,42 KiB