CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > ANSYS Meshing & Geometry

[Other] Spaceclaim scripting, get centroid of surface body

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 21, 2023, 03:15
Default Spaceclaim scripting, get centroid of surface body
  #1
DEd
Member
 
Daniel Edebro
Join Date: Feb 2016
Location: Gothenburg
Posts: 41
Rep Power: 10
DEd is on a distinguished road
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?
DEd is offline   Reply With Quote

Old   April 23, 2023, 05:27
Lightbulb
  #2
DEd
Member
 
Daniel Edebro
Join Date: Feb 2016
Location: Gothenburg
Posts: 41
Rep Power: 10
DEd is on a distinguished road
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)
DEd is offline   Reply With Quote

Reply

Tags
scripting, spaceclaim

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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 07:58
OpenFOAM error Vinay Kumar V Main CFD Forum 0 February 20, 2020 09:17
[DesignModeler] Merge Surface Body and Solid Body prikeyma ANSYS Meshing & Geometry 5 April 16, 2015 07:01
[DesignModeler] Boolean Subtract of a body and a surface KrishnaSandeep ANSYS Meshing & Geometry 2 April 1, 2015 15:55
[snappyHexMesh] Layers don't fully surround surface EVBUCF OpenFOAM Meshing & Mesh Conversion 14 August 20, 2012 04:31


All times are GMT -4. The time now is 20:20.