rmcanany / SolidEdgeHousekeeper

Utility for finding annoying little errors in your Solid Edge project
MIT License
23 stars 10 forks source link

Update Property & Variable Edit and Property Filter #123

Closed rmcanany closed 3 weeks ago

rmcanany commented 2 months ago

-- Incorporate User Controls (Supersedes https://github.com/rmcanany/SolidEdgeHousekeeper/issues/106) -- Deal with localized properties (Supersedes https://github.com/rmcanany/SolidEdgeHousekeeper/issues/109) -- Incorporate new TemplatePropertyList functionality -- Add Save/Retrieve/Delete for user inputs

farfilli commented 2 months ago

@rmcanany "Add Save/Retrieve/Delete for user inputs" where is this located? I don't get it

rmcanany commented 2 months ago

Oh, those are just planning statements. I'm going to work on it this week. I haven't uploaded anything yet.

farfilli commented 2 months ago

Sorry, misunderstood

rmcanany commented 2 months ago

Actually I think I was the one who misunderstood. You asked specifically about Save/Retrieve/Delete. That is like what you did with saved expressions, only for Find/Replace.

farfilli commented 2 months ago

Actually I think I was the one who misunderstood. You asked specifically about Save/Retrieve/Delete. That is like what you did with saved expressions, only for Find/Replace.

Yes that's it, I thought you had implemented yet nad couldn't find in the code; It's not mandatory but would be a nice addition beside the "Plans" for task lists

rmcanany commented 1 month ago

@farfilli I added the lookup functionality using property item numbers as you suggested. The mapping is from localized to English. I thought that would be more intuitive for the users.

I'm hoping you could run a test for me.

farfilli commented 1 month ago

Hi Robert, this is an holiday week in Italy. I'll take a look by the middle of next week.

rmcanany commented 1 month ago

Hey Francesco, that's cool. Enjoy your time off!

farfilli commented 1 month ago

@rmcanany I had a quick look and it seems the System properties list doesn't load on the combo box

image

rmcanany commented 1 month ago

Hmm. I'll check it out. That's in localized mode, right?

Not sure I mentioned it, but that list is populated on the Templates Tab. Any chance you didn't do that step?

copy_template_props

farfilli commented 1 month ago

I didn't check anything, and templates are not set at all. I would add a warning message or something to avoid this situation. I will retry again tomorrow

rmcanany commented 1 month ago

Good idea. Will do.

rmcanany commented 1 month ago

That warning should be there now. I added it for Property Filter and Edit Properties.

If you don't see it, try deleting the following files in the Preferences directory: form_main_settings.json template_property_dict.json template_property_list.json

farfilli commented 1 month ago

So I have added the templates and chosen the properties with the "UPDATE" button, which appears in both system and custom. This may lead to error and confusion by the user due to the fact that System properties will never have the custom ones

image

farfilli commented 1 month ago

I strongly recommend to have two separate properties lists, one for the Systems and one for the Customs properties

rmcanany commented 1 month ago

Actually, you don't need that. It's not obvious, but the listed properties know to which category they belong. Selecting the property sets the category. That's in the help topic, but of course no one reads that.

I need to come up with a way to make it obvious. I could maybe disable the System/Custom drop down when the list is populated. Or maybe I should just get rid of the category thing altogether. It's only there because SE allows duplicate names, which is a bad idea in my opinion. What do you think?

Oh, and back to the original question. Did the localized mapping work with Structured Storage?

farfilli commented 1 month ago

It's been some release that duplicates are not allowed and in case of legacy file you get a warning each time you open the properties page.

I would still prefer the two spare lists, or disable the combo and let the selected item set the combo accordingly.

Also I need the category for the direct edit, I need to check what happens with the latest changes.

rmcanany commented 1 month ago

I'll look into getting rid of the category (aka PropertySet).

If I understand your question, there isn't a separate category for direct edit. You just select the Edit outside SE option.

farfilli commented 1 month ago

Selecting a property doesn't correctly select the PropertySet image

rmcanany commented 1 month ago

That should be "Custom" I take it. Could you provide a sample file for me to play with? Maybe by email, or a message on the SE Forum.

farfilli commented 1 month ago

I think the problem is with any custom property

rmcanany commented 1 month ago

I tried it just now. It's working for me. Can you place a breakpoint and inspect TemplatePropertyDict to see what might be going wrong?

By the way, It doesn't currently update until the PropertyName gets a LostFocus event. But that's the same for either System or Custom.

farfilli commented 1 month ago

Can't test it untill Monday sorry

rmcanany commented 1 month ago

No sweat. Talk to you next week.

rmcanany commented 1 month ago

I removed the use of System. and Custom. from the code. I haven't updated the UI -- wanting to make sure it's likely to work before I start undoing a bunch of stuff.

If you get a chance to test it I would welcome any feedback. There are probably some bugs -- it has not been thoroughly tested by any means. By the way, I cleaned up the template properties to not show the unused ones. You'll need to run Update on the Templates Page to clean it up.

I haven't tried FOA or FOP with structured storage yet. I thought I might look at that next.

farfilli commented 1 month ago

I had a quick test and it seems to work both in interactive and in direct edit mode. One thing to consider is how the %{System.Property} should be written in formula syntax; in direct edit, it is mandatory that is not localized; I guess those who want to use that syntax should do some tests before proceeding. Proper documentation should be written.

rmcanany commented 1 month ago

OK, cool. Thank you.

I build a lookup table for translating localized to English. It gets populated when you run Update on the Templates Page. It uses your idea to map by Item Number. I added a check that the lookup table is populated for Run outside SE.

As I mentioned, System. and Custom. are going away. They're no longer used in the code. Once I do some more testing, I'll remove them from the UI.

That's a good point about the documentation. I'll make sure to mention it.

farfilli commented 1 month ago

I have this situation:

How do I specify which property to change/read if system. and custom. are removed?

This kind of maintenance on file is where HK does its best so I think we should handle duplicated property names. In fact I need to move the Custom.Revisione to System.Revision Number to fix the annoying duplicate property message on all the archive

rmcanany commented 1 month ago

Makes sense. I'll add that back in. I'm thinking I could make it optional. Can you think of a reason not to?

farfilli commented 1 month ago

I think it's a waste of code; Solid Edge users are familiar with the concept of custom properties and system(or we can call them standard?) properties therefore my first choice would be to leave them everywhere.

The autoselect of custom Vs system would be a nice thing but I would prefer 2 different combolist already filter accordingly to the selected group.

rmcanany commented 1 month ago

Good points. That's what I'll do. Thank you!

farfilli commented 1 month ago

One more thought: it could be that the system and custom are removed and auto determined accordingly and at the same time can also specify it manually

Example

Revision will automatically be the system one Custom.Revision will be the custom one

It this way we can handle the duplicated properties when present

Sorry to not have provided it before

rmcanany commented 1 month ago

That's more or less how I planned to do it. If the user picks the Category first, I'll filter the list. If they pick the Property first, I'll populate the Category.

Duplicates will appear in both filtered lists. I won't populate the Category for duplicates; I want to have the user make an intentional decision.

farfilli commented 1 month ago

And how you determine the duplicates? By template?

rmcanany commented 1 month ago

Yes, that was the idea. It's also possible to add a property to the customized list. I was thinking of adding a prompt for Property Set in that case.

I could be missing something. What do you think?

rmcanany commented 1 month ago

Uploaded some fixes just now. It isn't done. I still need to filter based on category selection.

rmcanany commented 1 month ago

@farfilli Filtering properties based on category selection should be working now. Let me know if you run into any issues, especially with duplicate property names and/or running localized.

farfilli commented 1 month ago

Property filter and category selections seems to work; however I experienced many missing system properties image

rmcanany commented 1 month ago

OK, thank you. I think I know what's going wrong. I'm filtering out a bunch of properties, like Number of Characters. I bet I'm not using the lookup table in that section of the code. I'll take a look today.

rmcanany commented 1 month ago

Sure enough. Pushed a fix just now.

farfilli commented 1 month ago

I done some test both direct and SE property manipulation and it seems to work fine. I found only 1 problem, when deleting a custom property, if the Find Text and Replace Text is not empty due to a previous usage you got an error

image

When "X" is selected those fields should be ignored, or another approach would be to black them when they became read-only

rmcanany commented 4 weeks ago

That's progress! I'll take care of that today. I found a couple of others -- -- The PropertyName combobox only populates Favorite properties even when Show All Props is enabled -- Property substitution entries in Find and Replace fields are not checked for %{Custom/System} -- Maybe add Customize Favorites to the shortcut menu for an easier way to manually add a property

rmcanany commented 4 weeks ago

Should be fixed now. Hopefully I didn't break something else in the process. (I haven't added the Customize Favorites shortcut yet.)

I really appreciate your help on testing, by the way.

rmcanany commented 3 weeks ago

@farfilli

I'm having trouble adding a new property with Edit Properties outside SE.

I added some breakpoints and it looks like the property is added. However, it doesn't show up in SE. I can't see it with SSView either. I added a Try/Catch. The command userProperties.PropertyNames.Keys.Max() + 1 was causing an exception. I tried a couple of other ways, but I'm just guessing.

If you get a chance to look at, that would be great. Otherwise I'll dig into it later this week.

farfilli commented 3 weeks ago

I have restored the .Max() + 1 method as it is the simplest way to get a unique valid ID. Can you provide more details on the exception error you get? I have tried with several files, the only problem I have encountered is on Family Of Assembly files; the properties storage has a different layout and it need a specific method to handle it.

farfilli commented 3 weeks ago

I have updated the OpenMcdf DLLs with #131 it is not a release but an improvement on the previous one. It should provide more details in case of exceptions in properties editing.

rmcanany commented 3 weeks ago

I was trying to add a new property to Coolunit.asm in the SE Training folder.

I added tmpProp to my Favorites -- Templates Page > Custom > RMB on Favorites > Manually add property.

I enabled the options: Add property and Run outside SE. Here's how I set up the Input Editor:

image

farfilli commented 3 weeks ago

Fixed with #132

rmcanany commented 3 weeks ago

I don't get the error message anymore, but some files are still not getting the new property. It appears to be those which have no custom properties at the outset.

I ran it on a copy of the SE2024 Training directory. After the run, I set up my Property Filter as shown. (Note the Formula). It's mostly .asm files, but I think that's because .par and *.psm almost always have Density and Accuracy in the Custom stream.

image

farfilli commented 3 weeks ago

You are right Robert if the Custom property is empty the property is not created. I'm going to investigate, there was an issue about this scenario.