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

How to write the script to measure perimeter in Spaceclaim?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 2, 2022, 07:50
Default How to write the script to measure perimeter in Spaceclaim?
  #1
New Member
 
Wu Yi-Lin
Join Date: Sep 2022
Posts: 2
Rep Power: 0
Joean is on a distinguished road
Hi, guys

I'm facing a difficulty:
In Spaceclaim, I created 424 faces in Sketch Mode in STL file because I want to measure the cross-sectional area and the perimeter of each face. And I wanted to write a script to make it measure automatically. However, there was an error message which is " 'Body' object has no attribute 'Perimeter' " when I tried to run the code to measure perimeter.

Here is my code below:
selection=FaceSelection.FilterByVisible(FaceSelect ion.SelectAll())
perimeter =list (face.Shape.Perimeter for face in selection.Items)
print(perimeter)

Can someone help me?

Thank you in advance,

Joean.
Joean is offline   Reply With Quote

Old   October 2, 2022, 17:31
Default
  #2
aeh
New Member
 
Austin
Join Date: Sep 2020
Posts: 3
Rep Power: 5
aeh is on a distinguished road
Quote:
Originally Posted by Joean View Post
Hi, guys

I'm facing a difficulty:
In Spaceclaim, I created 424 faces in Sketch Mode in STL file because I want to measure the cross-sectional area and the perimeter of each face. And I wanted to write a script to make it measure automatically. However, there was an error message which is " 'Body' object has no attribute 'Perimeter' " when I tried to run the code to measure perimeter.

Here is my code below:
selection=FaceSelection.FilterByVisible(FaceSelect ion.SelectAll())
perimeter =list (face.Shape.Perimeter for face in selection.Items)
print(perimeter)

Can someone help me?

Thank you in advance,

Joean.
You can loop through all the faces, select each edge of each face, then sum the length of each of those edges. You can do this first in the UI for an example edge while using the macro creation feature to see how it looks in the SpaceClaim API.
aeh is offline   Reply With Quote

Old   October 4, 2022, 03:02
Smile
  #3
New Member
 
Wu Yi-Lin
Join Date: Sep 2022
Posts: 2
Rep Power: 0
Joean is on a distinguished road
Quote:
Originally Posted by aeh View Post
You can loop through all the faces, select each edge of each face, then sum the length of each of those edges. You can do this first in the UI for an example edge while using the macro creation feature to see how it looks in the SpaceClaim API.
Hi,

Thank you for your reply.
That's a good idea that selects each edge of each face, and I will try later.
I've figured out another way to solve this problem.

Here is the modified code:
selection = FaceSelection.Create([GetRootPart().Bodies[0].Faces[0],
GetRootPart().Bodies[1].Faces[0],
GetRootPart().Bodies[2].Faces[0],
GetRootPart().Bodies[3].Faces[0],
...
GetRootPart().Bodies[423].Faces[0]])
perimeter =list(face.Shape.Perimeter for face in selection.Items)
print(perimeter)



Joean
Joean is offline   Reply With Quote

Reply

Tags
script error, spaceclaim


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
mesh file for flow over a circular cylinder Ardalan Main CFD Forum 7 December 15, 2020 13:06
[Helyx OS] Helyx-OS (GUI for SnappyHexMesh elvis OpenFOAM Community Contributions 210 January 30, 2017 18:57
[DesignModeler] How to write the script in the ansys design modeler? deddy1973 ANSYS Meshing & Geometry 3 October 4, 2013 05:08
how I can write the file script to submite via HPC cluster at my UNI happy CFX 2 October 17, 2011 02:18
pmovlink script Arnab Siemens 4 August 1, 2004 22:50


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