Property with speed unit mm/min is not saved in the layout

Hello,

I’m adding a real property with a speed unit to a process statement.
this property should be showing a speed value in mm/min.

so I program the following:

prop = stat.createProperty(VC_REAL, “Feed Rate”)
prop.Value=1000./60.
prop.Quantity = getApplication().findQuantity(‘Speed’)
prop.setUnitMagnitude(1./60.)

This works fine after the property is created. It shows mm/min and the value is calculated correct,
But after I save the layout and open it again the property show mm/s instead of mm/min and the value is re-calculated.

What is wrong with this?

Thanks.

Hi fredrik,

It looks like the issue is inputting 1/60 directly on the setUnitMagnitude. For any reason when I first copy pasted your code and cleaned it up a bit (forum text may not be pure text), I always got mm/s as the default magnitude. I think if you store 1/60 as a seperate variable first, and then input it in the setUnitMagnitude it would work. This little snippet also seems to work

from vcScript import *

comp = getComponent()


prop = comp.getProperty("Feed Rate")
if not prop:
  prop = comp.createProperty(VC_REAL, 'Feed Rate')


prop.Value=1000/60
prop.Quantity = getApplication().findQuantity('Speed')
#prop.setUnitMagnitude(1/60)

avail_groups = prop.Quantity.AvailableGroups

unit_g = avail_groups[0]
units = unit_g.Units

for u in units:
  print u.Name
  if u.Name == 'millimetres per minute':
    print u.Factor
    conversion = u.Factor


prop.setUnitMagnitude(conversion)  

br,
Lefa

Hi Lefa,

Thanks for the answer.
Did you save the layout, cleared the 3D window and re-opened the layout and checked if the unit is the same?

The issue is not to calculate the factor: 1./60. or 0.0166666667 or add it to a parameter, all works fine. The issue is that the unit is not the same after I re-open the layout. Maybe the setUnitMagnitude must be used every time a layout is opened?

Thanks,
Fredrik

Hi fredrik,

I did exactly that, I created a new component, saved the whole layout (with include components), cleared and reopened. The feed rate is still shown as mm/min.

test_python_mmpermin.vcmx (10.0 KB)

br,
Lefa

Hi Lefa,

Attached is an example similar to what I try to do.
A robot with one position statement. When you press start it will add a real property to the statement and change unit.
But after you save and reload the unit goes back to mm/s

Test Unit with Robot Statement.vcmx (1.5 MB)

the python script is in the robot component

Best regards,
Fredrik

Hi,

I can’t replicate this but I also modified it a bit.

image

I created the property, saved the layout, cleared the layout (ctrl + N) and then dropped the just saved layout into the 3d window and it still shows as mm/min

What version of VC are you using, I am using 4.6 so that might be the issue.

br,
Lefa

Hi,
I’m using version 4.6.
The problem is not with properties for components, but properties that are attached to a statement.

Hey Fredrik,

You are correct, I see it now. In order to get mm/min back you have to run the program (again) so it will rewrite the values of that statement. Not quite sure if that’s a bug because the vcmx file should save the robot program as well. I guess one workaround would be to use “OnAppInitialized” event where we would loop through all the statements of a robot and then check if it has “Feed Rate” property. If the statement has one, set its magnitude to 1/60.

br
Lefa