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

Property Data

Discussion in 'Alibre Script' started by idslk, Dec 4, 2019.

  1. idslk

    idslk Alibre Super User

    Hello Mika,
    Take a look into the alibre part data file properties
    upload_2019-12-27_18-24-6.png
    This is the format you have to use in the table.

    I've taken a look and saw you've used empty cells...
    In V01 i was to lazy to catch them...
    Appended is a patch which is capable to handle empty cells.

    Regards
    Stefan
     

    Attached Files:

    Mika likes this.
  2. NateLiqGrav

    NateLiqGrav Alibre Super User

    Might I suggest this alteration of the last few lines.
    Code:
    PropName = ('COMMENT', 'COST_CENTER', 'CREATED_BY', 'CREATING_APPLICATION', 'CREATED_DATE', 'DOCUMENT_NUMBER', 'ENG_APPROVAL_DATE', 'ENG_APPROVED_BY', 'ESTIMATED_COST', 'KEYWORDS', 'LAST_AUTHOR', 'LAST_UPDATE_DATE', 'MATERIAL', 'MFG_APPROVED_BY', 'MFG_APPROVED_DATE', 'MODIFIED', 'PRODUCT', 'RECEIVED_FROM', 'REVISION', 'STOCK_SIZE', 'SUPPLIER', 'TITLE', 'VENDOR', 'WEBLINK')
    ErrorCount = 0
    for prop in range(len(extdesprop_enum)):
      try:
        ThisSession.DesignProperties.ExtendedDesignProperty(extdesprop_enum[prop],str(propertytemplatedata[prop]))
      except:
        ErrorCount += 1
        print('The ' + str(PropName[prop]) + ' property could not be saved. Check that it is formated correctly')
    if ErrorCount:
      win.ErrorDialog( str(ErrorCount) + ' Errors have occured. Please check the Console for more info.\nSome Data had been written into your actual active file!','Error')
    else:
      win.InfoDialog('Data had been written into your actual active file!','Info')
     
  3. Lew_Merrick

    Lew_Merrick Alibre Super User

    Hi Stefan -- JJust to be clear I historically merely typed in a "YYYYMMDD" integer into that "entry" without a problem. -- Lew
     
  4. idslk

    idslk Alibre Super User

    Hello Nate,
    might be ok if you use extdesprop_enum instead of PropName because the enums are read automaticaly instead of typing...
    Therefor the loop: for i in System.Enum.GetValues(ADExtendedDesignProperty): is used ;-)
    The main reason that there is no additional error management and so on is: It is only a "quick techdemo"
    But more or less the code is open and everything could be added if somebody wants to ;-)
    Regards
    Stefan
     
  5. idslk

    idslk Alibre Super User

    Hello Lew,
    see post#18
    Regards
    Stefan
     
  6. NateLiqGrav

    NateLiqGrav Alibre Super User

    Thanks. I see that now. I had assumed that was only the values and not the names.

    Everyone: I believe Alibre uses the Windows Short Date format found (in Windows 7) by going to Control Panel > Region and Language > Formats
     
    Mika likes this.
  7. Mika

    Mika Senior Member

    Yeah, I get it working now. Thank you Stefan.
     
  8. idslk

    idslk Alibre Super User

    Hello colleagues, hello Lew ;-)
    on special request here the V21 update for the write file property script.
    Regards
    Stefan
     

    Attached Files:

  9. NateLiqGrav

    NateLiqGrav Alibre Super User

    Stefan, Have you gotten CustomProperty to work yet? I can't get that feature to work via API.
     
  10. Lew_Merrick

    Lew_Merrick Alibre Super User

    Hi Stefan -- Not that I have "tested" it yet, but thanks for the "update." As Nate has asked, "Any chance of adding Custom Properties?" [Irrational minds want to know!] -- Lew
     
  11. DavidJ

    DavidJ Alibre Super User Staff Member

    Lew,

    It's pretty simple - first you have to set up Custom Properties on your PC. In this example you'll need
    an Integer custom property called 'Cat' and a text custom property called 'Dog'. Obviously you can substitute any of your own existing properties.

    I've also included setting a 'standard property' using the new capability in v21

    Code:
    MyPart=CurrentPart()
    #set a part property
    MyPart.Vendor = 'Plasto'
    #set an integer custom property
    MyPart.SetCustomProperty('Cat','555')
    #set a text custom property
    MyPart.SetCustomProperty('Dog', 'Yorkie')
    output = MyPart.Vendor
    print(output)
    output = MyPart.GetCustomProperty('Cat')
    print(output)
    output = MyPart.GetCustomProperty('Dog')
    print(output)
    
    The code both sets, and then gets and prints 3 properties - you can also verify the setting in the part properties display.

    NOTE all values are passed from script as strings, the type comparison must be done in AD. So to avoid errors you migth want to add some format checking if you produce a 'real life' application.
     
  12. idslk

    idslk Alibre Super User

    add custom properties:
    upload_2020-5-9_19-4-44.png
    done

    take a look at:
    upload_2020-5-9_19-5-20.png
    looks ok.

    let's run the script and look at the console:
    upload_2020-5-9_19-6-9.png
    hm?

    control the properties:
    upload_2020-5-9_19-6-40.png

    Oh, what's this? the vendor property is written, but the custom properties not!!

    Important Hint:
    To get them written, the custom properties have to be filled with some values manually at creation.
    Otherwise they won't take your scripted values!
    upload_2020-5-9_19-9-28.png
    next try
    upload_2020-5-9_19-10-12.png
    and check
    upload_2020-5-9_19-11-32.png

    Thats' ok...

    have reported this behavior in the last days already...
    waiting for an answer since then...

    Regards
    Stefan
     
  13. NateLiqGrav

    NateLiqGrav Alibre Super User

    Ahhh, I manually created the custom properties but I had left them blank. It SHOULD be able to fill in a blank property - that's kind of the whole point in scripting it. Seems like a script should be able to create the property too.
     
  14. idslk

    idslk Alibre Super User

    reported that also and want to read the collection of custom properties...;)
     
    NateLiqGrav likes this.
  15. DavidJ

    DavidJ Alibre Super User Staff Member

    It filled property from scratch here. Though I did have the part open when I created them... maybe that is significant.

    I did hit a strange behaviour with one property that I've also reported.
     
  16. idslk

    idslk Alibre Super User

    Hello David,

    to show what i have done, i've made the step by step screenshots!
    New part, new custom properties and of course the part was open during creation.
    It only works if you have written a value to a custom property once!
    After this you can delete the value and leave the custom property empty and the script can write values into,
    but if you do not enter a value once manually the script isn't able to change the value!!!

    Regards
    Stefan
     
  17. DavidJ

    DavidJ Alibre Super User Staff Member

    Stefan, I was not doubting you - I just reported what I witnessed when coming up with that simple script for Lew.

    I did not enter values manually for Cat or Dog - I did run the script a few times before I got it correct to work at all, and maybe that had an effect. My Python experience is almost non-existent, and I find it much harder than the programming languages I'm used to. Hence several attempts / edits before it worked.
     
  18. Lew_Merrick

    Lew_Merrick Alibre Super User

    Hi Stefan -- Back in the latr-1970's I was "reasonable good" at FORTH coder. Python is still throwing me into the weeds. I copied your code and will "play" with it after I finish a (currently overdue) Project. -- Lew
     
  19. DavidJ

    DavidJ Alibre Super User Staff Member

    I've tried this again in a new file, I see same results now as you guys, values don't take for 'empty' properties. I've logged this with Development for investigation.
     
    NateLiqGrav likes this.
  20. DavidJ

    DavidJ Alibre Super User Staff Member

    This is resolved in v22 beta (22032).
     

Share This Page