I have a plot stamp im trying to tweek.
They were put together in a hurry from Curtis_w's posts and blog.
I dont have time to rework due to a massive project deadline fast approaching.
I had two rules showing date and time etc that were set to run on event trigger file save.
Now i need to add drafter name to this.
What i was trying to do was check if the custom prop PlotAuthor exists, and create it if it didnt.
Then I want to set the PlotAuthor to = the inventor username.
I failed in the timeframe i had 😞
I intended to combine these into one rule but dont have the time to work it out.
Curtis, you seem to have this stuff wired...if not combining them could you give me hand on at leat making rule 3 work please.
Any help would be greatly appreciated.
rule 1
PlotDateStamp
Dim odrawdoc As DrawingDocument
odrawdoc = ThisApplication.ActiveDocument
customPropertySet = odrawdoc.PropertySets.Item("Inventor User Defined Properties")
Try
prop = customPropertySet.Item("Plotdatestamp")
Catch
customPropertySet.Add("", "Plotdatestamp")
End Try
Try
Dim PlotDate As Date
PlotDate = Now
iProperties.Value("Custom", "Plotdatestamp") = PlotDate
Catch
End Try
InventorVb.DocumentUpdate()
rule 2
PlotTimeStamp
Dim odrawdoc As DrawingDocument
odrawdoc = ThisApplication.ActiveDocument
customPropertySet = odrawdoc.PropertySets.Item("Inventor User Defined Properties")
Try
prop = customPropertySet.Item("Plottimestamp")
Catch
customPropertySet.Add("", "Plottimestamp")
End Try
Try
Dim PlotTime As String
PlotTime = Now.ToShortTimeString
iProperties.Value("Custom", "Plottimestamp") = PlotTime
Catch
End Try
InventorVb.DocumentUpdate()
rule 3
PlotAuthorStamp
myName= ThisApplication.GeneralOptions.UserName
If iProperties.Value("Summary", "PlotAuthor") <> myName Then
iProperties.Value("Summary", "PlotAuthor") = myName
End If
InventorVb.DocumentUpdate()
Solved! Go to Solution.
Solved by Curtis_Waguespack. Go to Solution.
Hi richos69,
This should work (I didn't test it):
'rule 3 'PlotAuthorStamp myName= ThisApplication.GeneralOptions.UserName If iProperties.Value("Summary", "Author") <> myName Then iProperties.Value("Summary", "Author") = myName End If InventorVb.DocumentUpdate()
Or if you need to use "PlotAuthor", then you'll want to go the custom property route, like the others. I'll have another look, when I get a chance and have a go at combining them.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
thanks curtis
the Author property is already used in the title block for other info.
I need it for showing who plotted the drawing, as opposed to who created it.
I was going to run it on file open and on file save so if a person other than the document custodian (designer) opened it and made mods then printed it would leave a paper trail. (Large consultancy with a few rouge drafters causing problems)
Thats why i wanted to create the custom prop PlotAuthor from the application.username
The problem is with this line:
myName= ThisApplication.GeneralOptions.UserName
Try using:
myName = ThisApplication.UserName
This is in addition to the problem Curtis pointed out. To elaborate for him, you cannot add a property to the Summery prop set. You have to use the Custom prop set or one of the predefined properties in Summery.
So your code should look like:
'rule 3 'PlotAuthorStamp myName= ThisApplication.UserName If iProperties.Value("Custom", "PlotAuthor") <> myName Then iProperties.Value("Custom", "PlotAuthor") = myName End If InventorVb.DocumentUpdate()
Hi richos69,
Here is a rule that combines the three rules. I used mrattray's suggestion as well, but I didn't see any difference in using ThisApplication.UserName vs. ThisApplication.GeneralOptions.UserName. Attached is an example file for reference just in case my setup was a departure from yours, so you can compare. Or in case it helps someone in the future.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
'define the drawing Dim odrawdoc As DrawingDocument odrawdoc = ThisApplication.ActiveDocument 'define the property set customPropertySet = odrawdoc.PropertySets.Item("Inventor User Defined Properties") 'define the date string Dim PlotDate As Date PlotDate = Now 'define the time string Dim PlotTime As String PlotTime = Now.ToShortTimeString 'define the user name string Dim PlotName As String PlotName= ThisApplication.UserName '---------------- find or create custom properties ------------- 'look for the custom propety and add it if not found Try prop = customPropertySet.Item("Plotdatestamp") Catch customPropertySet.Add("", "Plotdatestamp") End Try 'look for the custom propety and add it if not found Try prop = customPropertySet.Item("Plottimestamp") Catch customPropertySet.Add("", "Plottimestamp") End Try 'look for the custom propety and add it if not found Try prop = customPropertySet.Item("PlotAuthor") Catch customPropertySet.Add("", "PlotAuthor") End Try '---------------- set the property values ----------------------- 'set the date property iProperties.Value("Custom", "Plotdatestamp") = PlotDate 'set the timeproperty iProperties.Value("Custom", "Plottimestamp") = PlotTime 'set the name property iProperties.Value("Custom", "PlotAuthor") = PlotName 'update the file InventorVb.DocumentUpdate()
thanks for the input mrattray
Curtis you are an absolute champion...that works perfectly.
It would have taken me ages to figure it out.
I havent programed much since cobol/fortran days.
Im liking the ilogic, i might get me some training 😉
(if i still need it after studying the crap out of your blog...nice work btw)