Inventor General Discussion

Inventor General Discussion

Reply
Valued Mentor
Rich.O.3d
Posts: 525
Registered: ‎08-19-2008
Message 1 of 6 (898 Views)
Accepted Solution

ilogic plot stamp - Curtis I need help please

898 Views, 5 Replies
06-06-2012 04:39 PM

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 :smileysad:

 

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()

 

 

CAD Management 101:
You can do it your own way,
If its done just how I say!
[Metallica:And Justice For All:1988]
*Expert Elite*
Curtis_Waguespack
Posts: 2,898
Registered: ‎03-08-2006
Message 2 of 6 (890 Views)

Re: ilogic plot stamp - Curtis I need help please

06-06-2012 06:44 PM in reply to: Rich.O.3d

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


 


 



  solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.





Valued Mentor
Rich.O.3d
Posts: 525
Registered: ‎08-19-2008
Message 3 of 6 (885 Views)

Re: ilogic plot stamp - Curtis I need help please

06-06-2012 07:29 PM in reply to: Curtis_Waguespack

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

CAD Management 101:
You can do it your own way,
If its done just how I say!
[Metallica:And Justice For All:1988]
*Expert Elite*
mrattray
Posts: 2,493
Registered: ‎09-13-2011
Message 4 of 6 (868 Views)

Re: ilogic plot stamp - Curtis I need help please

06-07-2012 05:29 AM in reply to: Rich.O.3d

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()

 

 

 

Mike (not Matt) Rattray

*Expert Elite*
Curtis_Waguespack
Posts: 2,898
Registered: ‎03-08-2006
Message 5 of 6 (849 Views)

Re: ilogic plot stamp - Curtis I need help please

06-07-2012 09:16 AM in reply to: Rich.O.3d

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()

 



  solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.





Valued Mentor
Rich.O.3d
Posts: 525
Registered: ‎08-19-2008
Message 6 of 6 (819 Views)

Re: ilogic plot stamp - Curtis I need help please

06-07-2012 05:39 PM in reply to: Curtis_Waguespack

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 :smileywink:

(if i still need it after studying the crap out of your blog...nice work btw)

CAD Management 101:
You can do it your own way,
If its done just how I say!
[Metallica:And Justice For All:1988]
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.