|
[Sponsors] |
[Other] Spaceclaim scripting, get centroid of surface body |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
April 21, 2023, 04:15 |
Spaceclaim scripting, get centroid of surface body
|
#1 |
Member
Daniel Edebro
Join Date: Feb 2016
Location: Gothenburg
Posts: 41
Rep Power: 10 |
Hi, I would like to create a script in spaceclaim that automatically creates a point at the centroid (center of an area) of a surface body (the surfaces are always planar in my use case if that helps).
1. Select surface 2. Run script and get a point at the centroid of that face. What I have tried: I have found the MeasureHelper class that has a method called MeasureHelper.GetCentroid that sound suitable. This method expects an object that implements ISelection. How do do I get an object that implements this? |
|
April 23, 2023, 06:27 |
|
#2 |
Member
Daniel Edebro
Join Date: Feb 2016
Location: Gothenburg
Posts: 41
Rep Power: 10 |
Just as an update. I found the solution to this problem myself.
This script works like this: 1. Select the faces you want to create the centroid for (note: don't select the surface bodies) 2. Run this script: Code:
# Python Script, API Version = V21 selected_items = Selection.GetActive().Items for selected_item in selected_items: if not isinstance(selected_item, DesignFace): continue sel_i = Selection.Create(selected_item) pt=MeasureHelper.GetCentroid(sel_i) new_pt=SketchPoint.Create(pt) |
|
Tags |
scripting, spaceclaim |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Gmsh] gmshToFoam generates patches with 0 faces and 0 points | Simurgh | OpenFOAM Meshing & Mesh Conversion | 4 | August 25, 2023 08:58 |
OpenFOAM error | Vinay Kumar V | Main CFD Forum | 0 | February 20, 2020 10:17 |
[DesignModeler] Merge Surface Body and Solid Body | prikeyma | ANSYS Meshing & Geometry | 5 | April 16, 2015 08:01 |
[DesignModeler] Boolean Subtract of a body and a surface | KrishnaSandeep | ANSYS Meshing & Geometry | 2 | April 1, 2015 16:55 |
[snappyHexMesh] Layers don't fully surround surface | EVBUCF | OpenFOAM Meshing & Mesh Conversion | 14 | August 20, 2012 05:31 |