Cancel
Showing results for 
Search instead for 
Did you mean: 

Line : Reverse Segments

Legend
Legend

Hello everyone, 

 

I'm trying to reverse segments in a line with SimTalk. How can I handle it ? 

We can do it manually like that : Right Click -> Segments -> Reverse ! 
But how can we do it witgh SimTalk ? 

Thank you very much 

BR
O.C

15 REPLIES

Re: Line : Reverse Segments

Phenom
Phenom

Re: Line : Reverse Segments

Legend
Legend

Thank you for your comment ! The conversation is quite interesting ! 

What I'm trying to do is to make two parallel lines spin around a point (black point as shown on the picture). 

 

I didn't find the formula to describe the rotation ! 

 

Thank you very much ! 

 

Capture.JPG

Re: Line : Reverse Segments

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor
You can use a transporter.
Create a transporter like here:
http://www.bangsow.de/detail_en.php?id=716

Add two transporter to the "turntable" with the loading bay type line. Works well.
Steffen Bangsow
freelance simulation specialist  
web: www.bangsow.eu
mail: steffen@bangsow.net

Re: Line : Reverse Segments

Gears Phenom Gears Phenom
Gears Phenom

Hello.

 

Have got me thinking a bit more, through drawing out a few conditions and plotting their coordinates in excel and then finding a circular fourmlar that passes through these points the equation needed can be found to do this. I always find it useful to place into excel the values you got to work with at the top so you know what is available and then test your fourmlar on multiple conditions at the same time to check for the results. 

 

Attached you will find the excel sheet I produced to solve this, I solved it for one of them only and then once I had tested and got that working in plant sim I then inverted the 'distance' component and used that for the other line.

 

var midPointX : real := 300
var midPointY : real := 300
var x : Real
var y : Real
var distance : real := 40


for var angle := 0 to 360
	Line.ObjectAngle := angle
	x := midPointX - (distance * sin((Line.ObjectAngle / 180) * Pi)) - (0.5 * Line.Length * (1 / ScalingFactor) * cos((Line.ObjectAngle / 180) * Pi))
	y := midPointY + (distance * cos((Line.ObjectAngle / 180) * Pi)) - (0.5 * Line.Length * (1 / ScalingFactor) * sin((Line.ObjectAngle / 180) * Pi))
	Line.SetPosition(round(x), round(y), false)
	
	Line1.ObjectAngle := angle
	x := midPointX + (distance * sin((Line.ObjectAngle / 180) * Pi)) - (0.5 * Line.Length * (1 / ScalingFactor) * cos((Line1.ObjectAngle / 180) * Pi))
	y := midPointY - (distance * cos((Line.ObjectAngle / 180) * Pi)) - (0.5 * Line.Length * (1 / ScalingFactor) * sin((Line1.ObjectAngle / 180) * Pi))
	Line1.SetPosition(round(x), round(y), false)
	
	wait 0.1
next

Hope you like it. As stated in the other thread, a lot can be done with a bit of code Smiley Wink

 

JamesM

Re: Line : Reverse Segments

Legend
Legend
Thank you very much James ! It's exactly what I'm talking about ! Smiley Happy
I have a question about the paramaters "Distance" and "ScalingFactor" what are they corresponding too ?

Thank you !

Re: Line : Reverse Segments

Legend
Legend
Thank you Steffen !
I had a look on your model, it's a genius way to handle the problem !
Thank you

Re: Line : Reverse Segments

Gears Phenom Gears Phenom
Gears Phenom

Hello

 

In this case, 'distance' is one of the varaibles within the method, it is the distance of your line from the mid point. Think of your line as a triangle, rotation point is 1 corner and the other is the referance point of the line with the hypotonose between them, the distance from the rotation point to the middle of the line is 1 side and the other is half the length of the line object. This should help you to also see how the furmlar is constructed using these 2 components.

 

The 'ScallingFactor' is a part of the frame, it is the attribute that links the pixels in the 2D frame to your length unit (most likely meters) and by default is 0.05, meaning 1 pixel is 5cm, as the grid spacing is 20 pixels apart then it means each grip spacing is 1m apart.

 

JamesM

Re: Line : Reverse Segments

Legend
Legend
Okay ! Now it's more than clear ! Smiley Happy
Thank you again, I'll write it today and keep you in touch !

Have a nice day !
BR
O.C

Re: Line : Reverse Segments

Legend
Legend

I tried the code but it's exactly what I was looking for ! 
May I ask you to have a look on the attachement .spp. 

Normally the two lines should stay parrallel