Creating a wire from a line/arc
Solved
Python API
-
So in Sim4Life I can create a line and through the GUI it is possible to give this line a certain thickness (using the modify tab and clicking thicken wire). However I cannot seem to find this option in the Sim4Life API, does anyone know if this is possible? I'm using V3.4.1.2244
So a snippet of the code I use is given belowimport s4l_v1.model as model from s4l_v1.model import Vec3 import math Wire1 = model.CreateArc(Vec3(0,0,0), 10, float(10)/180*math.pi,float(350)/180*math.pi) Wire1.Name = 'MetalWire' # Thicken Wire...
-
So I sort of found the solution...
import s4l_v1.model as model from s4l_v1.model import Vec3 import math import XCoreModeling def get_spline_length(spline): wire = XCoreModeling.GetWires(spline)[0] return wire.GetLength() def Thicken_Wire(spline,radius): wire = XCoreModeling.GetWires(spline)[0] target_curve = wire.GetGeometry(transform_to_model_space=True) # compute the length of the spline height = get_spline_length(spline) # get the Vec3 of the starting and end points startVec = target_curve.Eval(0.0) endVec = target_curve.Eval(height) # create a cylinder that will be bend to the spline, its height must be the same as the length of the spline Wire1 = XCoreModeling.CreateSolidCylinder(startVec,Vec3(startVec[0]-height,startVec[1],startVec[2]),radius) # do the bending XCoreModeling.BendBodyToCurve(Wire1,startVec,Vec3(startVec[0]-height,startVec[1],startVec[2]),Vec3(0,0,1),target_curve) # remove the used spline spline.Delete() return Wire1 # example spline1 = model.CreateArc(Vec3(0,0,0), radius, float(10)/180*math.pi,float(350)/180*math.pi) Wire1 = Thicken_Wire(spline1,1)
-
Thanks, I was wondering if there is a way for me to flag this as 'solved'?
-
Okay good to know!