Symbol Factory Component and Change Scripts

Good afternoon Team,

Is there a way to take a symbol like a the Extended pusher 1 (selected), place it inside a view in perspective, and use the Y coordinate to “move” it up and down based the CurrentLevel of the component?

In VISION we used this script tied to the component.


[details="Summary"]
if event.propertyName == 'CurrentLevel':
	if event.source.CurrentLevel > 0 and event.source.CurrentLevel < 31:
		comp = event.source.parent.getComponent('Level ' + str(event.source.CurrentLevel))
		yPos = comp.getY()
	elif event.source.CurrentLevel == 31:
		comp = event.source.parent.getComponent('H1')
		yPos = comp.getY() + 15
	elif event.source.CurrentLevel == 32:
		comp = event.source.parent.getComponent('H2')
		yPos = comp.getY() + 15
	elif event.source.CurrentLevel == 35:
		comp = event.source.parent.getComponent('I Location')
		yPos = comp.getY() + 15
	else:
		yPos = 100
	
	
	system.gui.transform(event.source, newY=yPos, duration=1000, acceleration=system.gui.ACCL_FAST_TO_SLOW)
[/details]

		

Anyone?

Remember I just want the crane at the bottom (selected) to move up and down the y coordinate.

You can bind to the Y position or you should be able to set in a script as well.

Yeah, seconding what jlandwerlen said.

I would do a binding on the y coordinate. Connect it to your ‘CurrentLevel’ value, and then you can do a similar script to what you had in vision within a script transform, just remove the system.gui.transform line and return your yPos instead.

How would i do that exactly?

I am not very versed in python.

Right-click on CurrentLevel and add a change script.

image

Calculate it like you normally would and sent the result to (in this instance) self.position.y

Add a transition to the style.

Thanks Jordan, once again.

I got it to work by binding the template to the current level then adding a mapping of the physical location to for each level. Probably not the most efficient. I will try your way.

If it works, it works. :wink: You could just add the transition for the motion effect.

Morning Jordan,

I am really interested in how your set up works. What does the y = 100 + currentValue.value * 15 do? Specifcally the 100 and the *15.

In my new screen i have added an index and startX that was used while in vision. I have tweaked the index from 16 to 44.5 so that when the crane homes it will be in the same location.

My issues is that it almost goes off the screen to the left and it does not line up directly with the actual green squares, which are bin locations. I am not sure what to tweak to correct it.

I have bound the x position to the multiplier and the multiplier has the expression below.

if({[default]Warehouse/Dambach Cranes/Crane 1/Crane Report/Actual Position Rack Field} > 1,
(({[default]Warehouse/Dambach Cranes/Crane 1/Crane Report/Actual Position Rack Field} * 2) - 3) * {parent.custom.index} +
	if({[default]Warehouse/Dambach Cranes/Crane 1/Crane Report/Actual Position Rack Field} = 2,
	{parent.custom.index},
	0),
if({[default]Warehouse/Dambach Cranes/Crane 1/Crane Report/Actual Position Rack Field} = -1,
-{parent.custom.index}*2,
200))


It was just a fluff function. 100 pixels for a base value + 15 pixels per whole value of currentValue.

So, think of the 100 as a ‘home’ position, and the 15 being the center-to-center distance between your squares…

Jordan, if I have this statement below do i actually need the = 1, 200 in the first part?

I think if i am reading this correctly, if i leave the = 1 part if it 1 and not > then it will look at the expression and return 200 due to the last part?

Summary
if({[default]Warehouse/Dambach Cranes/Crane 2/Crane Report/Actual Position Rack Field} = 1, 200, if({[default]Warehouse/Dambach Cranes/Crane 2/Crane Report/Actual Position Rack Field} > 1,
(({[default]Warehouse/Dambach Cranes/Crane 2/Crane Report/Actual Position Rack Field} * 0.01) + 0.01) * {parent.custom.index} + {parent.custom.startX} +
	if({[default]Warehouse/Dambach Cranes/Crane 2/Crane Report/Actual Position Rack Place} = 2,
	{parent.custom.index},
	0),
if({[default]Warehouse/Dambach Cranes/Crane 2/Crane Report/Actual Position Rack Field} = -1,
{parent.custom.index}*4.6,
200)))

Disregard, that is not right…

You have to figure out your index when the screen loads. In vision it’s in pixels and depending on the screen resolution, the number of pixels between boxes will be different so you have to calculate that when the screen is activated. I’m not sure what that is in perspective but there is a script that runs on the window open of the vision window to calculate that value.

It’s something like: (X position of the last box - X position of the first box) / number of boxes

I guess I need some help.

In my root container I have 2 custom props, index = 35 and startX = 200.

On my moving crane I have a custom prop named Multiplier where I hold my expression, which right now it is this, but it is wrong.


[details="Summary"]
if({[default]Warehouse/Dambach Cranes/Crane 1/Crane Report/Actual Position Rack Field} = 1, 200, if({[default]Warehouse/Dambach Cranes/Crane 1/Crane Report/Actual Position Rack Field} > 1,
(({[default]Warehouse/Dambach Cranes/Crane 1/Crane Report/Actual Position Rack Field} * 1) + 0.01) * {parent.custom.index} + {parent.custom.startX} +
	if({[default]Warehouse/Dambach Cranes/Crane 1/Crane Report/Actual Position Rack Place} = 2,
	{parent.custom.index},
	0),
if({[default]Warehouse/Dambach Cranes/Crane 1/Crane Report/Actual Position Rack Field} = -1,
{parent.custom.index}*4.6,
200)))
[/details]

I want my 1 position to start at 200, then based on rackfield and rackplace it needs to increase by the index.

Example:
2 1 would be 235
2 2 would be 270
3 1 would be 305
3 2 would be 340

With in my racking it is numbered like this up to approx 30.

Rackfield Rackplace
1 1
2 1
2 2
3 1
3 2
4 1
4 2

Try:
200 + (rackfield-1) * 70 + (rackplace-1) * 35
EDIT: Close, but not quite.

What I’m saying is that your starting position of 200 and the index may not be what it is when you are not in the designer because that is all relative. You should set the starting position as the X position of the first box and then calculate what the index should be from the position of the boxes on the screen at runtime.

The algorithm is:
max(200, 235 + (rackfield-2) * 70 + (rackplace-1) * 35)
Since there is no [1,2] spot, [2,1] becomes the origin spot at 235. if we try to calculate with rackfield 1, the value goes less than 200, so the max function returns 200.

for rackfield in range(1, 31): # 1 to 30
	for rackplace in range(1, 3):# 1 to 2
		x =  max(200, 235 + (rackfield-2) * 70 + (rackplace-1) * 35)
		print [rackfield, rackplace], x
[1, 1] 200
[1, 2] 200
[2, 1] 235
[2, 2] 270
[3, 1] 305
[3, 2] 340
[4, 1] 375
[4, 2] 410
[5, 1] 445
[5, 2] 480
[6, 1] 515
[6, 2] 550
[7, 1] 585
[7, 2] 620
1 Like