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

Scripting Help Please

Discussion in 'Alibre Script' started by albie0803, Aug 24, 2020.

  1. albie0803

    albie0803 Alibre Super User

    New problem

    Why doesn't this work?

    60. arc1=S.AddArcCenterStartAngle(0,0,A1X,A1Y,A1A*2,False) #Works fine
    61. arc2=S.AddArcCenterStartAngle(0,0,A2X,A2Y,A2A*2,True) #Works fine
    62. arc3=S.AddArcCenterStartAngle(0,0,A3X,A3Y,A3A*2,False) #Works fine
    64. S.AddBspline([arc1.StartPoint, arc2.StartPoint, arc3.StartPoint], False)

    I get the error

    File "<string>", line 64, in <module>
    Exception: Failed to convert a value into a real value
    Last edited: Aug 30, 2020
  2. albie0803

    albie0803 Alibre Super User

    New Problem above
  3. idslk

    idslk Alibre Super User

    Hello Allen,

    I can't "translate" the Error message into something meaningfull, but, longer as neccessary, i can make something like your code (i had no lines 1 to 59...) working...
    cp = CurrentPart()
    s = cp.AddSketch('Arcs', cp.XYPlane)
    A1X = 10
    A1Y = 10
    A2X = 20
    A2Y = 25
    A3X = 15
    A3Y = 15
    A1A = 25
    A2A = 30
    A3A = 15
    print '_________________\n'
    print arc1.StartPoint, arc2.StartPoint, arc3.StartPoint
    print '_________________\n'
    print A1X,A1Y
    print A2X,A2Y
    print A3X,A3Y
    s.AddBspline([A1X,A1Y,A2X,A2Y,A3X,A3Y], False)
    I hope it helps.

  4. NateLiqGrav

    NateLiqGrav Alibre Super User

    I'm not at my pc but I think this should work:
    S.AddBspline([arc1.StartPoint.X, arc1.StartPoint.Y, arc2.StartPoint.X, arc2.StartPoint.Y, arc3.StartPoint.X, arc3.StartPoint.Y], False)
  5. idslk

    idslk Alibre Super User

    Hello Nate,

    as far as Allen calculates (maybe) the values for A1X and A1Y (and the others) which represent the startpoints of the arcs, it is not neccessary to use arc1.Startpoint.X (which does not work. Instead you can use arc1.Startpoint[0]) because it is given with A1X.

  6. albie0803

    albie0803 Alibre Super User

    Thanks all for the responses, but WHY doesn't S.AddBspline([arc1.StartPoint, arc2.StartPoint, arc3.StartPoint], False) work?
    This works, line3=S.AddLine(line2.EndPoint, arc2.EndPoint, False), so why isn't the syntax valid for splines?

    If it's a case of it needs to programmed then it should be, Please.

    Rant Time:
    I looked at the reference guide for the correct syntax for a BSpline and as usual, If you already know, then it is a helpful reminder, but if you don't know, then it's no help at all as there are no examples of syntax!!

    AddBspline([X1, Y1, X2, Y2,.....],False) would have made all the difference!!

    Every item in the reference guide should have at least 1 example of acceptable syntax

    It would make learning and using so much easier.
    simonb65 likes this.
  7. NateLiqGrav

    NateLiqGrav Alibre Super User

    I was wrong slightly. Here is what I was trying to remember but the names are confusing:
    SketchPoints have a .X and .Y so this code should work:
    S.AddBspline([arc1.Start.X, arc1.Start.Y, arc2.Start.X, arc2.Start.Y, arc3.Start.X, arc3.Start.Y], False)
  8. simonb65

    simonb65 Alibre Super User

    Start and End naming not being consistent with Center, doesn't help!
    Last edited: Aug 31, 2020
  9. Lew_Merrick

    Lew_Merrick Alibre Super User

    Hi Albie -- What we need is Documentation (written with non-coders in mind) with Examples (and a really good Index)! -- Lew
    simonb65 likes this.
  10. Lew_Merrick

    Lew_Merrick Alibre Super User

    Hi Stefan -- A couple of weeks ago I sent you a "private contact" asking for help. I have a Library of Parts that were taken over by a "new" manufacturing company. Thus, the "values" for (File Properties>General>Part Data) >Document Number, >Keywords, and >Supplier have all changed. I have arrays of values for "Old_File_Names" and "New_File_Names" as well as "Document_ID" as well as the new name of the "Supplier" that I need to update. I am getting nowhere in hyperdrive trying to fisure out how to accomplish this. ??? Irrational minds want to know. -- Lew
  11. idslk

    idslk Alibre Super User

    Hello Lew,

    can you post an example/screenshots here?

  12. Lew_Merrick

    Lew_Merrick Alibre Super User

    Hi Stefan -- The attached image shows the "values" I need to change. They are (within the File Properties->General->Part Data) listing the Document Identity and Vendor designations. I created them when I created the Part Files, but as I said the Company has changed hands and Part Numbers (as well as the Vendor) are being changed. -- Lew Part Change Data.PNG
  13. idslk

    idslk Alibre Super User

    Are these "arrays" are part of spreadsheet tables? Can you also post a sniplet of those?
  14. Lew_Merrick

    Lew_Merrick Alibre Super User

    Hi Stefan -- My data is defined by:
    FilePath = "J:\\Lews_Data\\Designs\\Alibre_Standards\\Press Nuts\\UN Press Nuts\\"
    File_Names = ["Nut 0-0860-56UNC-1.AD_PRT","Nut 0-0860-56UNC-2.AD_PRT","Nut 0-0860-56UNC-3.AD_PRT","Nut 0-1120-40UNC-1.AD_PRT","Nut 0-1120-40UNC-2.AD_PRT","Nut 0-1120-40UNC-3.AD_PRT","Nut 0-1120-40UNC-4.AD_PRT","Nut 0-1380-32UNC-1.AD_PRT","Nut 0-1380-32UNC-2.AD_PRT","Nut 0-1380-32UNC-3.AD_PRT","Nut 0-1380-32UNC-4.AD_PRT","Nut 0-1640-32UNC-1.AD_PRT","Nut 0-1640-32UNC-2.AD_PRT","Nut 0-1640-32UNC-3.AD_PRT","Nut 0-1640-32UNC-4.AD_PRT","Nut 0-1900-24UNC-1.AD_PRT","Nut 0-1900-24UNC-2.AD_PRT","Nut 0-1900-24UNC-3.AD_PRT","Nut 0-1900-24UNC-4.AD_PRT","Nut 0-1900-32UNF-1.AD_PRT","Nut 0-1900-32UNF-2.AD_PRT","Nut 0-1900-32UNF-3.AD_PRT","Nut 0-1900-32UNF-4.AD_PRT","Nut 0-2160-24UNC-2.AD_PRT","Nut 0-2160-24UNC-3.AD_PRT","Nut 0-2160-24UNC-4.AD_PRT","Nut 0-2160-24UNC-5.AD_PRT","Nut 0-2500-20UNC-2.AD_PRT","Nut 0-2500-20UNC-3.AD_PRT","Nut 0-2500-20UNC-4.AD_PRT","Nut 0-2500-20UNC-5.AD_PRT","Nut 0-2500-28UNF-3.AD_PRT","Nut 0-2500-28UNF-4.AD_PRT","Nut 0-3125-18UNC-3.AD_PRT","Nut 0-3125-18UNC-4.AD_PRT","Nut 0-3125-18UNC-5.AD_PRT","Nut 0-3125-24UNF-3.AD_PRT","Nut 0-3125-24UNF-4.AD_PRT","Nut 0-3750-16UNC-4.AD_PRT","Nut 0-3750-16UNC-5.AD_PRT","Nut 0-3750-16UNC-6.AD_PRT","Nut 0-3750-24UNF-5.AD_PRT","Nut 0-5000-13UNC-5.AD_PRT","Nut 0-5000-13UNC-6.AD_PRT","Nut 0-5000-20UNF-5.AD_PRT"]
    Part_No = ["Self-Clenching Nut S-256-1","Self-Clenching Nut S-256-2","Self-Clenching Nut S-256-3","Self-Clenching Nut S-440-2","Self-Clenching Nut S-440-2","Self-Clenching Nut S-440-3","Self-Clenching Nut S-440-4","Self-Clenching Nut S-632-1","Self-Clenching Nut S-632-2","Self-Clenching Nut S-632-3","Self-Clenching Nut S-632-4","Self-Clenching Nut S-832-1","Self-Clenching Nut S-832-2","Self-Clenching Nut S-832-3","Self-Clenching Nut S-832-4","Self-Clenching Nut S-1024-1","Self-Clenching Nut S-1024-2","Self-Clenching Nut S-1024-3","Self-Clenching Nut S-1024-4","Self-Clenching Nut S-1032-1","Self-Clenching Nut S-1032-2","Self-Clenching Nut S-1032-3","Self-Clenching Nut S-1032-4","Self-Clenching Nut S-1224-2","Self-Clenching Nut S-1224-3","Self-Clenching Nut S-1224-4","Self-Clenching Nut S-1224-5","Self-Clenching Nut S-0420-2","Self-Clenching Nut S-0420-3","Self-Clenching Nut S-0420-4","Self-Clenching Nut S-0420-5","Self-Clenching Nut S-0428-3","Self-Clenching Nut S-0428-4","Self-Clenching Nut S-0518-3","Self-Clenching Nut S-0518-4","Self-Clenching Nut S-0518-5","Self-Clenching Nut S-0524-3","Self-Clenching Nut S-0524-4","Self-Clenching Nut S-0616-4","Self-Clenching Nut S-0616-5","Self-Clenching Nut S-0616-6","Self-Clenching Nut S-0624-5","Self-Clenching Nut S-0813-5","Self-Clenching Nut S-0813-6","Self-Clenching Nut S-0820-5"]
    I hope this helps -- Lew
  15. idslk

    idslk Alibre Super User

    Hello Lew,

    i'm not sure that i understood you completely.
    You have files in a windows folder. This files have to be renamed and the Design Property Data inside the files has also to be adjusted accordingly?

  16. Lew_Merrick

    Lew_Merrick Alibre Super User

    Hi Stefan -- Yes. If you wish, I can post the Drive & File Path to the Directory in which they are stored. -- Lew
  17. idslk

    idslk Alibre Super User

    Hello Lew,

    here's the first shot to play with it...

    I've copied the data of your post#14 into the script. Please double-check that!

    i havn't done so much evaluation (5 rounds with 3 parts on one of my disks, but using your "Part_No" list)...


    it's only for test purposes. I've deactivated the line with the "Save command"


    Comments are welcome.

    To use the script, you have to open a (new / blank) part and start the script there. Don't use a part you want to adjust.
    The script runs through your File list, opens each file, adjusts the according number and (if activated) saves and closes the file.

    Console output from testrun:

    changed Property:

    "Slow Down" dialog:


    Please be carefull!
    Make a Backup of your data before executing the script!
    If you change the script, be sure about your modifications and check them twice!

    As ever: The use of the script is your own risk!!! I do not make any guarantees!!!


    Attached Files:

    TimoCAD likes this.
  18. Lew_Merrick

    Lew_Merrick Alibre Super User

    Hi Stefan -- Thanks (I hope). In essence a "guide" to adjusting information in the "Part Data" arena is what I am hoping for so that I can actually learn something. I used to be a moderately decent programmer with "CP/M FORTH" code (which ought to be a dead give away to my age). -- Lew
  19. idslk

    idslk Alibre Super User

    Hello Lew,

    8 days gone since..., i hope you have learned something...

  20. Lew_Merrick

    Lew_Merrick Alibre Super User

    Hi Stefan -- Sorry, I had to "leap" to assist our younger grandkids. -- Lew

Share This Page