icon

Forum de la communauté Allplan

[Question] Gravity Center [Résolu]

Balises:
  • 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

Pièces-jointes (3)

Type: image/png
Téléchargé 58 fois
Size: 66,33 KiB
Type: image/png
Téléchargé 39 fois
Size: 64,27 KiB
Type: image/png
Téléchargé 33 fois
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

Pièces-jointes (2)

Type: application/x-sqlite3
Téléchargé 488 fois
Size: 132,00 KiB
Type: image/png
Téléchargé 44 fois
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 ?

Pièces-jointes (1)

Type: image/png
Téléchargé 46 fois
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)

Pièces-jointes (1)

Type: application/x-7z-compressed
Téléchargé 548 fois
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

Pièces-jointes (1)

Type: image/png
Téléchargé 38 fois
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

Pièces-jointes (1)

Type: application/zip
Téléchargé 528 fois
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

Pièces-jointes (2)

Type: application/x-sqlite3
Téléchargé 488 fois
Size: 132,00 KiB
Type: image/png
Téléchargé 44 fois
Size: 62,42 KiB