-
-
February 9, 2024 at 5:14 pm
Hussam Khresat
SubscriberHi all,Â
I am trying to apply a face split command to an extruded skecth using design modeler scripting and I am not sure how to do so.Â
Attached is my code to create the sketch and extrude it.
Any help will be greatly appreciated
//DesignModeler JScript, version: Ansys DesignModeler 2021 R2 (Jun 1 2021, 09:34:08; 21,2021,151,1) SV4//Created via: "Write Script: Sketch(es) of Active Plane"// Written to: C:\Users\47111601\Downloads\HK_Ansys\HK_Ansys2021\SYS-2.js// On: 02/06/24, 23:16:48//Using:// agb ... pointer to batch interfaceÂ//Note:// You may be able to re-use below JScript function via cut-and-paste;// however, you may have to re-name the function identifier.//Âfunction planeSketchesOnly(p) {  //Plane  p.Plane = agb.GetActivePlane(); // Retrieve the YZ plane  var YZPlane = agb.GetYZPlane();  // Set YZ plane  p.Plane = YZPlane;  p.Origin = p.Plane.GetOrigin();  p.XAxis = p.Plane.GetXAxis();  p.YAxis = p.Plane.GetYAxis();  //Sketch  p.Sk1 = p.Plane.NewSketch();  p.Sk1.Name = "Sketch1";  //Edges  with(p.Sk1) {    p.Ln7 = Line(0.00000000, 6.00000000, 0.20465000, 6.00000000);    p.Ln8 = Line(0.20465000, 6.00000000, 0.20465000, -6.00000000);    p.Ln9 = Line(0.20465000, -6.00000000, -0.20465000, -6.00000000);    p.Ln10 = Line(-0.20465000, -6.00000000, -0.20465000, 6.00000000);    p.Ln12 = Line(0.00000000, 6.00000000, -0.20465000, 6.00000000);  }  //Dimensions and/or constraints  with(p.Plane) {    //Dimensions    var dim;    dim = HorizontalDim(p.Ln7.Base, 0.00000000, 6.00000000,      p.Ln7.End, 0.20465000, 6.00000000,      0.35164860, 8.54551913);    if (dim) dim.Name = "H1";    dim = HorizontalDim(p.Ln9.Base, 0.20465000, -6.00000000,      p.Ln9.End, -0.20465000, -6.00000000,      0.02566448, -7.24440432);    if (dim) dim.Name = "H4";    dim = VerticalDim(p.Origin, 0.00000000, 0.00000000,      p.Ln7.End, 0.20465000, 6.00000000,      0.88851166, 5.68672685);    if (dim) dim.Name = "V2";    dim = VerticalDim(p.Ln8.Base, 0.20465000, 6.00000000,      p.Ln8.End, 0.20465000, -6.00000000,      1.32459557, 0.28560604);    if (dim) dim.Name = "V3";    //Constraints    HorizontalCon(p.Ln7);    HorizontalCon(p.Ln9);    HorizontalCon(p.Ln12);    VerticalCon(p.Ln8);    VerticalCon(p.Ln10);    CoincidentCon(p.Ln7.Base, 0.00000000, 6.00000000,      p.YAxis, 0.00000000, 4.48815214);    CoincidentCon(p.Ln8.Base, 0.20465000, 6.00000000,      p.Ln7.End, 0.20465000, 6.00000000);    CoincidentCon(p.Ln9.Base, 0.20465000, -6.00000000,      p.Ln8.End, 0.20465000, -6.00000000);    CoincidentCon(p.Ln10.Base, -0.20465000, -6.00000000,      p.Ln9.End, -0.20465000, -6.00000000);    CoincidentCon(p.Ln12.Base, 0.00000000, 6.00000000,      p.Ln7.Base, 0.00000000, 6.00000000);    CoincidentCon(p.Ln12.End, -0.20465000, 6.00000000,      p.Ln10.End, -0.20465000, 6.00000000);    EqualLengthCon(p.Ln10, p.Ln8);  }  p.Plane.EvalDimCons(); //Final evaluate of all dimensions and constraints in plane  // Extrude the sketch only in the X-direction  var ext1 = agb.Extrude(agc.Add, p.Sk1, agc.DirX, agc.ExtentFixed, 72, agc.ExtentFixed, 0.0, agc.No, 0.0, 0.0);  agb.Regen(); // Regenerate the model to ensure validity  return p;} //End Plane JScript function: planeSketchesOnlyÂ//Call Plane JScript functionvar ps1 = planeSketchesOnly(new Object());Â
-
February 13, 2024 at 7:48 am
mjmiddle
Ansys EmployeeDesignModeler is in maintenance mode. Have you considered using SpaceClaim to do your geometry modifications inside Ansys applications?
The only script type that DM records is jscript and only in sketch mode. When they were first implementing sripting in workench application, they decided on python interpreter. And they started implementing python scripting in DM, but it was soon-after placed into maintenance mode, so they stopped the work on python scripting implementation DM. So there is some python scipting ability in DM, but it's not developed to the degree of Mechanical, SpaceClaim, or workbench. This is an old course in the Ansys Learning Hub:
-
February 13, 2024 at 7:57 am
mjmiddle
Ansys EmployeeYou can have a python script and run your jscript code:
Must be in an extension scope when running from the ACT console for the ExecuteCommand to exist. Example:
ExtAPI.Application.ScriptByName("jscript").ExecuteCommand(jscript_command_string) -
February 13, 2024 at 8:10 am
mjmiddle
Ansys EmployeeWithin an ACT extension inside DM, it may be possible to split a face using the imprint under ExtAPI.DataModel.GeometryBuilder.Operations.Tools:
Or maybe the face split could be done as a slice.
The only way to do a slice in batch, as part of a user-defined feature in an ACT extension, is to do it as part of an extrude or sweep operation, since you can choose the option to slice while extruding or sweeping:
feature.MaterialType = MaterialTypeEnum.Slice
Example called by: def generateSlice(feature, fct):
  builder = ExtAPI.DataModel.GeometryBuilder  bodies=[]
  squarePri = builder.Primitives.Sheet.CreatePolygon([0.,0.,0.,1.,0.,0.,1.,0.,1.,0.,0.,1.])
  # You can apply the extrude to a sketch, line body, face, or surface body
  squareBody = squarePri.Generate()
  feature.MaterialType = MaterialTypeEnum.Slice
  extrudeOperation = builder.Operations.CreateExtrudeOperation([0.,1.,0.],15.)
  #extrudeOperation.Depth
  #extrudeOperation.Direction
  #extrudeOperation.Walled
  extrudeBodies = extrudeOperation.ApplyTo(squareBody)
  # doesn't seem to be a way to slice through only target bodies
  bodies.extend(extrudeBodies)
  feature.Bodies = bodies
  return TrueOr it may be possible to make some python commands to insert the native "Face Split" feature you would see in the Outline and set selections and any other necessary options, but I don't see an examples of this done yet.
-
- The topic ‘Face split in design modeler scripting’ is closed to new replies.
-
6044
-
1906
-
1431
-
1308
-
1021
© 2026 Copyright ANSYS, Inc. All rights reserved.

