Hey,

sure the code is below. Can I ask for what purpose you are modelling random wires?

Cheers,

```
# get spline function to create random wires
import XCore
import os
import XCoreModeling
import s4l_v1 as s4l
import s4l_v1.model as model
import numpy as np
Vec3 = s4l.Vec3
def get_spline_length(spline):
wire = XCoreModeling.GetWires(spline)[0]
return wire.GetLength()
def Thicken_Wire(spline,radius,flagDelete):
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)
print(height)
# 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
if flagDelete:
spline.Delete()
return Wire1
def CreateRandomWire(radiusWire,radiusIns,randomness,flagDeleteSplines):
# randomize the x-coordinate
xCor = np.random.rand(10,1)*randomness - randomness/2
# uncomment if you want to randomize y too
yCor = np.random.rand(10,1)*randomness - randomness/2
# set the same starting point for all the wires
points = [Vec3(0.0,0.0,0.0)]
for j in range(10):
# for random x coordinate
#points.append(Vec3(xCor[j][0],0.0,20.0*(j+1)))
# uncomment for random x and y coordinate
points.append(Vec3(xCor[j][0],yCor[j][0],20.0*(j+1)))
# create the random spline
a = model.CreateSpline(points)
# if you want the wire to be insulated set the radius of the Ins higher then 0
# this creates the wires
if radiusIns > 0.0:
Ins = Thicken_Wire(a,radiusIns,False)
Wire = Thicken_Wire(a,radiusWire,flagDeleteSplines)
return Wire,Ins
else:
Wire = Thicken_Wire(a,radiusWire,flagDeleteSplines)
return Wire
# Start of main script, change parameters as you like here
NumberofWires = 10
#create the separate simulations
for i in range(NumberofWires):
# start by making the random wire with insulation
[RandomWire,RandomIns] = CreateRandomWire(1.25,2.0,15.0,True)
RandomWire.Name = 'RandomWire' + str(i+1)
RandomIns.Name = 'RandomIns' + str(i+1)
#possible to make a simulation in the same loop.
```