The reference point for the icon is not used as the icon is not used. For length based objects the icon is generated depending on the length of the object so the reference point instead is the point in which everything is measured from so the middle of the start of the object.
To get it to rotate around its centre point instead you need to calculate its center point and store it (avoids multiple rounding errors) and then use that center point to calculate a new xPos and yPos to move it to after it has been rotated.
More mean to caculate the midpoints at the start of the method and then you can change the 'ObjectAngle' attribute to rotate it as long as after you add in a few lines to change the posistion of it where it should be.
var midPointX : real
var midPointY : real
midPointX := Line2.XPos + (0.5 * Line2.Length * (1 / ScalingFactor) * cos((Line2.ObjectAngle / 180) * Pi))
midPointY := Line2.YPos + (0.5 * Line2.Length * (1 / ScalingFactor) * sin((Line2.ObjectAngle / 180) * Pi))
for var angle := 0 to 360
Line2.ObjectAngle := angle
var x : Real := midPointX - (0.5 * Line2.Length * (1 / ScalingFactor) * cos((Line2.ObjectAngle / 180) * Pi))
var y : Real := midPointY - (0.5 * Line2.Length * (1 / ScalingFactor) * sin((Line2.ObjectAngle / 180) * Pi))
Line2.SetPosition(round(x), round(y), false)
The above code should work, should find its center point and then start to rotate, at each stage it will recenter itself around the center point. Personally I like to use the ObjectAngle more as it is a built in attribute that can be used multiple times instead of editing the segments table lots of times. Also in new versions of Plant Sim there is a curve table instead.
I think this method is not friendly enough and I see many applications for that.
It's an opportunity to develop a tool in plant simulation to make easier this kind of application (rotate lenght based objects through a reference point defined by the user).
Please forward this suggestion to continuous improvement team!