How to generate parametric geometry in Discovery using scripting?

Erik Kostson
Member, Moderator, Employee Posts: 312
✭✭✭✭
Is it possible to generate parametric geometry in Discovery using scripting, and is there an example?
0
Best Answer
-
Yes it is.
Below is a simple example of a cylindrical shell with radius = Rad (parameter), and height = Hei (parameter).
First open the script editor inside Discovery, and activate Embed Script (slide nr 10 / step1: see link below). After that we get the parameter icon (slide nr 10 / step 3).
As shown in the above link, define the 2 parameters needed for the below script (Rad, and Hei).
In the script editor paste the below script, and run it in order to generate the geometry:
r=Parameters.Rad h=Parameters.Hei sectionPlane = Plane.PlaneXY result = ViewHelper.SetSketchPlane(sectionPlane, None) origin = Point2D.Create(M(0), M(0)) results = SketchCircle.Create(origin, M(r)) mode = InteractionMode.Section result = ViewHelper.SetViewMode(mode, None) selection = Selection.Create(GetRootPart().DatumPlanes[0].Curves[0]) options = ExtrudeEdgeOptions() result3 = ExtrudeEdges.Execute(selection,M(h), options) GetRootPart().DatumPlanes[0].Delete() mode = InteractionMode.Solid result = ViewHelper.SetViewMode(mode, None) selected_body = Selection.Create(GetRootPart().Bodies[0]) secondarySelection = Selection.Empty() # Create a new named selection group with the selected faces result = NamedSelection.Create(selected_body, secondarySelection, "Mysel")
0
This discussion has been closed.