Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ilogic plot stamp - Curtis I need help please

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
Rich.O.3d
3903 Views, 5 Replies

ilogic plot stamp - Curtis I need help please

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

 

 

CAD Management 101:
You can do it your own way,
If its done just how I say!
[Metallica:And Justice For All:1988]
5 REPLIES 5
Message 2 of 6

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


 


 

Message 3 of 6

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]
Message 4 of 6
mrattray
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

Message 5 of 6

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

 

Message 6 of 6

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)

CAD Management 101:
You can do it your own way,
If its done just how I say!
[Metallica:And Justice For All:1988]

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report