1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Code no longer working

Discussion in 'Alibre Script' started by albie0803, Feb 3, 2019.

  1. albie0803

    albie0803 Alibre Super User

    Code:
    Options = []
    Options.append([None, WindowsInputTypes.Label, 'Enter values below from your model']) #[0]
    Options.append(["Select Origin Face", WindowsInputTypes.Face, None]) #[1]
    Options.append(["Select Reference Face", WindowsInputTypes.Face, None]) #[2]
    Options.append(["Select Shaft Edge", WindowsInputTypes.Edge, None]) #[3]
    
    
    OF = Values[1] # Origin Face
    RF = Values[2] # Reference face
    E = Values[3] # Edge Value
    SEF = OF.DistanceTo(RF)
    print SEF
    
    This used to work but now all I get is SEF=0

    I have restarted Alibre and also rebooted the machine to no avail.

    I had a look at this thread and it seems to be related. I have investigated further and if the face normals are in the same direction I get a correct answer but if they oppose then I get 0. I thought from the mentioned thread that this was only an issue when the opposing planes were equidistant from the origin but now it seems not.

    This script used to work so something has changed somewhere.
     
    Last edited: Feb 3, 2019
  2. idslk

    idslk Senior Member

    Hello albie0803,

    it seems that the values of the vectors are simply added (including their directions). This means that a distance to the "left" of 3 added with a distance to the "right" of 5 will be treated like (-3) + (+5) will give a result of 2. This differs from the value, which is shown correctly in the measurement tool.
    So if one of your faces is on the "+ side" of the origin plane and the other face is on the "- side" you will get unexpected results.
    That's a job for Andy...and as he already said "Fixed for the next release"

    Regards
    Stefan
     
  3. albie0803

    albie0803 Alibre Super User

    In my script OF is always 0 and in this case RF = 350
    OF points left and RF points right, which probably gives something like -350 which I guess would be unacceptable, as distances should be > 0, so it gives 0.

    Well I hope the next release isn't too far away and that we get line numbers back in error messages like we used to have as well.
     
  4. idslk

    idslk Senior Member

    Hello Albie0803,

    are you working in an assembly or in a single part?

    Regards
    Stefan
     
  5. albie0803

    albie0803 Alibre Super User

    Single part
     
  6. idslk

    idslk Senior Member

    Hello albie0803,

    have drawn a part diameter 50, length 350 based on XYPlane
    upload_2019-2-4_10-50-20.png
    and used "your skript"
    Code:
    Win = Windows()
    CP = CurrentPart()
    ScriptName = 'Test'
    
    Options = []
    Options.append([None, WindowsInputTypes.Label, 'Enter values below from your model']) #[0]
    Options.append(["Select Origin Face", WindowsInputTypes.Face, None]) #[1]
    Options.append(["Select Reference Face", WindowsInputTypes.Face, None]) #[2]
    Options.append(["Select Shaft Edge", WindowsInputTypes.Edge, None]) #[3]
    Values = Win.OptionsDialog(ScriptName, Options, 100)
    if Values == None:
      sys.exit()
     
    OF = Values[1] # Origin Face
    RF = Values[2] # Reference face
    E = Values[3] # Edge Value
    SEF = OF.DistanceTo(RF)
    print SEF
    
    upload_2019-2-4_10-51-33.png

    And it prints out 350
    upload_2019-2-4_10-52-31.png

    Can you add the skript with the part?

    Regards
    Stefan
     
  7. albie0803

    albie0803 Alibre Super User

    The part must be corrupt. Your script runs fine in a new part but not in my template part.
     

    Attached Files:

  8. idslk

    idslk Senior Member

    Hello albie0803,

    this is interesting. I've added to new made shafts without details! They are made from scratch, no copy of your file!!
    One which is made of a revolved sketch like yours and one which is made of 3 extruded cylinders.
    The revolved one gives wrong values, the extruded one works well.
    Has to be investigated i think.

    Regards
    Stefan
     

    Attached Files:

  9. NateLiqGrav

    NateLiqGrav Alibre Super User

    I can confirm.
     
  10. ajayre

    ajayre Alibre Super User

    In both example parts the result is zero because the faces are not parallel. They appear to be parallel as far as the user can tell but internally there is an extremely small rounding/precision problem that makes them appear to not be parallel to the code.

    Fixed for the next release but unfortunately there isn't a workaround.

    Andy
     
  11. albie0803

    albie0803 Alibre Super User

    Good to hear there is a fix on the way, hope it isn't too long.
    The silver lining for me is that I decided to redo my shaft template with extruded shapes and did it on the X axis which all my scripts use. Now I can stop trying to rewrite my scripts for a Z axis. So yay! :)
     

Share This Page