Cancel
Showing results for 
Search instead for 
Did you mean: 

Line - Rotate around reference point

Builder
Builder

hello,

 

in the attached model, if the reference point of the line is in it's center, why doesnt it rotate around the center?

8 REPLIES

Re: Line - Rotate around reference point

Phenom
Phenom

I assume "rotateAroundRefPoint" is for symbols and not for curves.

 

In any case where did you set the ref point for Line2 ?

Re: Line - Rotate around reference point

Gears Phenom Gears Phenom
Gears Phenom

Hello.

 

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.

 

JamesM

Re: Line - Rotate around reference point

Builder
Builder

for line2 the option to calculate the reference point is not enabled. I dont know how to re-sefine that.

Re: Line - Rotate around reference point

Phenom
Phenom

to change the reference point, you have to switch off the inheritance in ribbon.

But this is only valid for symbols.

Re: Line - Rotate around reference point

Phenom
Phenom

i think this is what jamesM means

Unbenannt.png

Re: Line - Rotate around reference point

Gears Phenom Gears Phenom
Gears Phenom

Hello

 

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)
wait 0.1
next

 

 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.

 

JamesM

Re: Line - Rotate around reference point

Builder
Builder

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!

 

Thanks.

 

 

Re: Line - Rotate around reference point

Gears Phenom Gears Phenom
Gears Phenom

A little bit of code can go a long way.