Set up WithEvents structure, ChangeCustomPropertyNotify
Set up WithEvents structure, ChangeCustomPropertyNotify
(OP)
Howdy,
I'm having difficulty setting up a WithEvents structure. I've used one previously, but, this seems to be a little different. The code I used previously was triggered by a user selection on a drawing sheet (views, notes, sheet etc.). This time I need to get an event from a change in the Custom Properties (Summary Information, Custom tab). I'm not sure if it's even possible, but, according to what I reading in the SW API help, I should be able to.
My goal is to run a form with a ListBox that displays all of the existing Custom Properties, then, while the form is still showing, allow the user to open (Shift + p) and change the Custom Properties, then, when that window is closed the ChangeCustomPropertyNotify function is triggered in the macro. I will use that event to update the ListBox to the revised Custom Properties (automatic update triggered by the change in the custom properties). I know I can make a button to do the update, but, wanted to make it automatic.
I've attached the macro I've been experimenting with. I have a feeling I'm either close or way off
.
Can someone help me set up this WithEvents structure?
Thanks
I'm having difficulty setting up a WithEvents structure. I've used one previously, but, this seems to be a little different. The code I used previously was triggered by a user selection on a drawing sheet (views, notes, sheet etc.). This time I need to get an event from a change in the Custom Properties (Summary Information, Custom tab). I'm not sure if it's even possible, but, according to what I reading in the SW API help, I should be able to.
My goal is to run a form with a ListBox that displays all of the existing Custom Properties, then, while the form is still showing, allow the user to open (Shift + p) and change the Custom Properties, then, when that window is closed the ChangeCustomPropertyNotify function is triggered in the macro. I will use that event to update the ListBox to the revised Custom Properties (automatic update triggered by the change in the custom properties). I know I can make a button to do the update, but, wanted to make it automatic.
I've attached the macro I've been experimenting with. I have a feeling I'm either close or way off
Can someone help me set up this WithEvents structure?
Thanks
Tobin Sparks
www.nov.com






RE: Set up WithEvents structure, ChangeCustomPropertyNotify
You ned to monitor for changes in active document, then set PartDoc, AssemblyDoc, or DrawingDoc accordingly. You will need to set up three sets of events to catch each type.
Don't forget to give handleman a star.
RE: Set up WithEvents structure, ChangeCustomPropertyNotify
Thanks
Tobin Sparks
www.nov.com
RE: Set up WithEvents structure, ChangeCustomPropertyNotify
-handleman, CSWP (The new, easy test)
RE: Set up WithEvents structure, ChangeCustomPropertyNotify
Tobin Sparks
www.nov.com
RE: Set up WithEvents structure, ChangeCustomPropertyNotify
In the listbox to the side will list all configurations in the open part:
Global = Part level custom properties
Everything else = Configuration level custom properties
(I have sorting so with a new setup having only 00 thru 99 configuration names, I won't have the "default" part 00 shown in the list to supercede the "global" properties)
I took a minute and removed the configuration sorting. (Note that if you click a configuration name in the list it automatically adds properties if they don't exist. If they do it will pull that information and enter into the text boxes)
Might be good reference for whatever you're trying to do.
Good luck. It was a fun project getting that stuff working. If you're confused by all of the wierd stuff in my macro it's mostly sorting so it recognizes custom properties with any case sensitivity and deletes anything I'm not presently allowing. (Basically automated house cleaning to get old parts and bad practice up to snuff)
If you have any questions with it holler.
James Spisich
Design Engineer, CSWP
RE: Set up WithEvents structure, ChangeCustomPropertyNotify
Select the method: PropCode.Main
Otherwise you won't get too far. =D
James Spisich
Design Engineer, CSWP
RE: Set up WithEvents structure, ChangeCustomPropertyNotify
Very nice Company-specific Custom Properties macro. I noticed it runs ShowModal = True. So the user can't access any other windows until there finished with the macro. I need to run the macro ShowModal = False because the user may need to access the FeatureManager design tree or the SW Summary Information window to make changes. Then I'd like the macro to automatically update. Maybe I'm expecting to much for a macro
Thanks again for your response
Tobin Sparks
www.nov.com
RE: Set up WithEvents structure, ChangeCustomPropertyNotify
What is it exactly you're trying to accomplish? It looks like you're just doing custom property management yes?
Do you have a standard list of properties you use? Can you just dump these to individual textboxes instead of a list? What is the purpose for using this as listbox? etc, etc.
Just curious to get more of the back story than what you gave.
James Spisich
Design Engineer, CSWP
RE: Set up WithEvents structure, ChangeCustomPropertyNotify
That being said, I found this macro in my stash. I don't remember writing it, but I can't for the life of me remember where I got it. Maybe it was from the API support section of SW, or maybe from "the Schwarz." I dunno. Basically, all it does is beep or notify you with a MsgBox when the active document is rebuilt. The ActiveDocChangeNotify function is really important. It makes sure that the active document is always pointed to by either ListenerPartDoc, ListenerDwgDoc, or ListenerAssyDoc. I guess you know, you can only register for events inside UserForm code or in a Class Module. This macro includes code for both.
-handleman, CSWP (The new, easy test)
RE: Set up WithEvents structure, ChangeCustomPropertyNotify
-handleman, CSWP (The new, easy test)
RE: Set up WithEvents structure, ChangeCustomPropertyNotify
RE: Set up WithEvents structure, ChangeCustomPropertyNotify
It'll take me a while to look into the macro you uploaded.
Thanks
Jspisich,
Attached is our complete Custom Properties macro. Well - complete in the sense that it reflects our current engineering department practices and default Custom Properties (which change from time to time).
<What is the purpose for using this as listbox? etc, etc.>
The ListBox (only for Assembly and Part Docs) gives the user an immediate look into the existing Custom Properties, so he/she can determine if it contains mistakes that need to be repaired. If the mistakes are minor the user can just use the Apply button to add any missing default Custom Properties. We didn't want to make a macro that deleted anything, the user has to do that purposely.
I guess I'm just trying to get rid of the Reload button. Seems minor, but, would make the macro closer to what I consider complete.
Thanks
Tobin Sparks
www.nov.com
RE: Set up WithEvents structure, ChangeCustomPropertyNotify
<You need to monitor for changes in active document, then set PartDoc, AssemblyDoc, or DrawingDoc accordingly.>
This makes more sense to me now. In my experiment macro I'm just working with PartDoc for now. If I get that to work I'm sure I can do the rest.
Thanks
handleman,
As usual - very helpful information.
I was able to follow RebuildMonitor.swp to change my code to make it work - sort of. I can get RegenPostNotify2 to cause the WithEvents action to run properly, but, can't seem to get a reaction out of ChangeCustomPropertyNotify.
Attached is the almost working macro.
Anybody have any ideas why that might be?
Thanks
Tobin Sparks
www.nov.com
RE: Set up WithEvents structure, ChangeCustomPropertyNotify
-handleman, CSWP (The new, easy test)
RE: Set up WithEvents structure, ChangeCustomPropertyNotify
Thanks for your input. That seems to help.
Tobin Sparks
www.nov.com