CFD Online Logo CFD Online URL
Home > Forums > Software User Forums > Siemens > STAR-CCM+

Renaming surfaces in macro

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

LinkBack Thread Tools Search this Thread Display Modes
Old   December 1, 2019, 15:08
Default Renaming surfaces in macro
New Member
Jack B
Join Date: Jul 2018
Posts: 8
Rep Power: 4
Jack B is on a distinguished road
Hi all,

I tried looking around for a previous post on this issue but I couldn't find anything.

I have recorded a macro in Star-CCM+. In this macro I create a block, split it by patch and rename surfaces (ie. Inlet, Outlet, etc.). I see in the macro that each surface is given a specific ID number.

The issue arises when I run the macro again, the surfaces are given different ID numbers every time a new Star-CCM+ file is created so the Macro can not rename them as it does not find them.

Is there any way to rename surfaces without using this ID number or is there a way to make sure that the ID number is the same every time?

Thanks in advance,

Jack B is offline   Reply With Quote

Old   December 1, 2019, 19:39
Senior Member
Chaotic Water
Join Date: Jul 2012
Location: Elgrin Fau
Posts: 248
Rep Power: 13
cwl is on a distinguished road
Originally Posted by Jack B View Post
Is there any way to rename surfaces without using this ID number
To be honest - I doubt that.
I remember some macros from macrohut that could do similar things - but that was long ago and lots of those capabilities are now implemented into Star.

or is there a way to make sure that the ID number is the same every time?
Again - I do not thing so nsice generation of IDs is done according to Star's internal algorithms.

I'm pretty sure that your problem can be solved in much easier way.
Can you please descibe it more detailed?
cwl is offline   Reply With Quote

Old   December 2, 2019, 17:36
Senior Member
Sebastian Engel
Join Date: Jun 2011
Location: Germany
Posts: 555
Rep Power: 17
bluebase will become famous soon enough
Hi Jack,

yes you can, but it is likely less convenient.

are you creating the box manually by sketch, or are you using a box primitive?
If you use the latter you get methods to get the top and buttom surfaces easily. See the example below. But i assume you need settings for the sides as well?

Anyways, you also can iterate through the list of faces. If you create just a box, the order and orientation will always be the same, and you might just sequentially set the names.
For arbitrary sketch-based bodies, this should work quite similar.
Inspect the example below where the collection of faces is created. You do not need to know the names or ids to get the collection. (you can use similar methods to get a collection of bodies).

For more complex geometries, you might need to compare some additional properties. The loop has some additional lines

Or, you pick faces by location - inspect the end of the script.
This approach might be most versatile, if you can compute coordinates where your surfaces are, and when they are not too small and close to each other.

best regards,

import java.util.*;

import star.cadmodeler.*;
import star.common.*;
import star.base.neo.*;
import star.vis.*;

public class box extends StarMacro {

  public void execute() {
    Simulation simulation_0 = getActiveSimulation();

    // Start making CAD
    Scene scene_0 = simulation_0.getSceneManager().createScene("3D-CAD View");

    CadModel cadModel_0 = simulation_0.get(SolidModelManager.class).createSolidModel(scene_0);;

   // SceneUpdate sceneUpdate_0 = scene_0.getSceneUpdate();

    Units units_0 = 
      simulation_0.getUnitsManager().getPreferredUnits(new IntVector(new int[] {0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}));
    LabCoordinateSystem labCoordinateSystem_0 = 

    // Prepare box feature
    BlockPrimitiveFeature blockPrimitiveFeature_0 = cadModel_0.getFeatureManager().createBlockPrimitiveFeature();

    // Set the box center location
    CadModelCoordinate cadModelCoordinate_0 = blockPrimitiveFeature_0.getCenter();
    cadModelCoordinate_0.setCoordinate(units_0, units_0, units_0, new DoubleVector(new double[] {0.0, 0.0, 0.0}));

    // Set the dimensions of the block

    // Create the box

    // rename patches
    Face face_0 = 
      ((Face) blockPrimitiveFeature_0.getTopFace());
    cadModel_0.setFaceNameAttributes(new NeoObjectVector(new Object[] {face_0}), "inlet");

    Face face_1 = 
      ((Face) blockPrimitiveFeature_0.getBottomFace());
    cadModel_0.setFaceNameAttributes(new NeoObjectVector(new Object[] {face_1}), "outlet");
    // Probably what you mentioned, faces by id
        Face face_4 = 
      ((Face) blockPrimitiveFeature_0.getSideFace("1"));

    cadModel_0.setFaceNameAttributes(new NeoObjectVector(new Object[] {face_4}), "wall");
    // get all faces
        star.cadmodeler.Body cadmodelerBody_1 = 
      ((star.cadmodeler.Body) blockPrimitiveFeature_0.getBody());    
    Collection<Face> faces = cadmodelerBody_1.getFaceManager().getFaces();
    for(Face face : faces) {
        // face names

        // extracting properties from face
        NeoProperty properties = cadmodelerBody_1.getFaceManager().getFaceProperties(new Vector<Face>(Arrays.asList(face)));
        //get Face normal
        Vector<Double> normalVector =properties.getNeoProperty(String.valueOf(face.getEntityId())).getDoubleVector("Normal");

    // Get Face by Location
    double[] picLocation = new double[]{-0.05, 0.0, 0.2};
    Face faceByLoc = cadModel_0.getFaceByLocation(cadmodelerBody_1,new DoubleVector(picLocation));
    simulation_0.println("Near " + Arrays.toString(picLocation) + " found Face: " + faceByLoc.getPresentationName());
    // Renaming found surface
    cadModel_0.setFaceNameAttributes(new NeoObjectVector(new Object[] {faceByLoc }), "FaceByLocation");

    // Finish CAD
    simulation_0.getSceneManager().deleteScenes(new NeoObjectVector(new Object[] {scene_0}));

bluebase is offline   Reply With Quote


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
fvOptions npatricia OpenFOAM 6 May 23, 2018 05:21
NURBS surfaces on a wing frossi CFX 5 February 5, 2017 15:27
timestep extraction for macro manuc Tecplot 0 August 10, 2016 12:20
Modeling both radiation and convection on surfaces - Ansys Transient Thermal R13 s.mishra ANSYS 0 March 31, 2012 04:12
Macro problem cfddummy Siemens 1 April 9, 2007 12:37

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