Putting System Date in to a Drawing?

Putting System Date in to a Drawing?

Anonymous
Not applicable
626 Views
7 Replies
Message 1 of 8

Putting System Date in to a Drawing?

Anonymous
Not applicable
I have no programming skills so I am asking something that may be over
my head but....

I have Prompted Entries for my custom Title Block in an .idw. Some of
the prompted entries are the date, time and file name of the .idw.

Is there a way to make a button or pulldown function that could extract
that information from the operating system and put it in to the prompted
entry? I would also want to run that function when the drawing was
saved.

Steve Krause
sk@dolby.com
0 Likes
627 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable
Hi Steve

While I can't say for absolute, I doubt it is possible right now. Very little of the IDW
has been exposed to vba yet. Hopefully next release.

--
Kent


"-Steve-Krause-" wrote in message news:3BF01267.8BB11266@dolby.com...
> Is there a way to make a button or pulldown function that could extract
> that information from the operating system and put it in to the prompted
> entry?
0 Likes
Message 3 of 8

Anonymous
Not applicable
Steve,

This VBA example will add the system date and time as 2 custom properties in
a drawing (just run the VBA once in a drawing to create the to properties).
To make it work you have to add 2 property fields in the title block
referring to the custom fields.

It would be possible to add this code to an add-in so the values will be
updated every time you save a drawing, but this will take some more
programming to accomplish.

Hope this helps.

-Patrick

Copy and Paste into default.ivb:

Public Sub AddSysDateTime()

On Error Resume Next

'Check if the active document is a Drawing
If ThisApplication.ActiveDocumentType = kDrawingDocumentObject Then

'Add a custom property "SysDate" with system date
Set oPropSet =
ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B
2CF9AE}")
'As a workaround the property must be delete if it exist because it can
not be changed
oPropSet.Item("SysDate").Delete
Call oPropSet.Add(Date, "SysDate")

'Add a custom property "SysTime" with system time
Set oPropSet =
ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B
2CF9AE}")
'As a workaround the property must be delete if it exist because it can
not be changed
oPropSet.Item("SysTime").Delete
Call oPropSet.Add(Format(Time, "hh:mm"), "SysTime")

End If

End Sub


"-Steve-Krause-" wrote in message
news:3BF01267.8BB11266@dolby.com...
| I have no programming skills so I am asking something that may be over
| my head but....
|
| I have Prompted Entries for my custom Title Block in an .idw. Some of
| the prompted entries are the date, time and file name of the .idw.
|
| Is there a way to make a button or pulldown function that could extract
| that information from the operating system and put it in to the prompted
| entry? I would also want to run that function when the drawing was
| saved.
|
| Steve Krause
| sk@dolby.com
0 Likes
Message 4 of 8

Anonymous
Not applicable
Boy shoe leather tastes bad... 8^)

--
Kent


"Patrick de Stobbeleir" wrote in message
news:FA3318F4C9B7A840E0B4792363C21DF4@in.WebX.maYIadrTaRb...
> Steve,
>
> This VBA example will add the system date and time as 2 custom properties in
> a drawing (just run the VBA once in a drawing to create the to properties).
0 Likes
Message 5 of 8

Anonymous
Not applicable
hi hi Patrick,
There is word wrap in you procedure. There is no space between these
funny numbers and the second line?
Ole


"Patrick de Stobbeleir" wrote in message
news:FA3318F4C9B7A840E0B4792363C21DF4@in.WebX.maYIadrTaRb...
> Steve,
>
> This VBA example will add the system date and time as 2 custom properties
in
> a drawing (just run the VBA once in a drawing to create the to
properties).
> To make it work you have to add 2 property fields in the title block
> referring to the custom fields.
>
> It would be possible to add this code to an add-in so the values will be
> updated every time you save a drawing, but this will take some more
> programming to accomplish.
>
> Hope this helps.
>
> -Patrick
>
> Copy and Paste into default.ivb:
>
> Public Sub AddSysDateTime()
>
> On Error Resume Next
>
> 'Check if the active document is a Drawing
> If ThisApplication.ActiveDocumentType = kDrawingDocumentObject Then
>
> 'Add a custom property "SysDate" with system date
> Set oPropSet =
>
ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B
> 2CF9AE}")
> 'As a workaround the property must be delete if it exist because it
can
> not be changed
> oPropSet.Item("SysDate").Delete
> Call oPropSet.Add(Date, "SysDate")
>
> 'Add a custom property "SysTime" with system time
> Set oPropSet =
>
ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B
> 2CF9AE}")
> 'As a workaround the property must be delete if it exist because it
can
> not be changed
> oPropSet.Item("SysTime").Delete
> Call oPropSet.Add(Format(Time, "hh:mm"), "SysTime")
>
> End If
>
> End Sub
>
>
> "-Steve-Krause-" wrote in message
> news:3BF01267.8BB11266@dolby.com...
> | I have no programming skills so I am asking something that may be over
> | my head but....
> |
> | I have Prompted Entries for my custom Title Block in an .idw. Some of
> | the prompted entries are the date, time and file name of the .idw.
> |
> | Is there a way to make a button or pulldown function that could extract
> | that information from the operating system and put it in to the prompted
> | entry? I would also want to run that function when the drawing was
> | saved.
> |
> | Steve Krause
> | sk@dolby.com
>
>
0 Likes
Message 6 of 8

Anonymous
Not applicable
>
> Copy and Paste into default.ivb:
>
> Public Sub AddSysDateTime()
>
> On Error Resume Next
>
> 'Check if the active document is a Drawing
> If ThisApplication.ActiveDocumentType = kDrawingDocumentObject Then
>
> 'Add a custom property "SysDate" with system date
> Set oPropSet =
> ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B
> 2CF9AE}")
> 'As a workaround the property must be delete if it exist because it can
> not be changed
> oPropSet.Item("SysDate").Delete
> Call oPropSet.Add(Date, "SysDate")
>
> 'Add a custom property "SysTime" with system time
> Set oPropSet =
> ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B
> 2CF9AE}")
> 'As a workaround the property must be delete if it exist because it can
> not be changed
> oPropSet.Item("SysTime").Delete
> Call oPropSet.Add(Format(Time, "hh:mm"), "SysTime")
>
> End If
>
> End Sub
>



I found a default.ivb file in Program files\Autodesk-\Inventor
5\Bin\Macros but it appears to be a compiled (nontext) file. Should I
really copy and paste in to that file?

Steve Krause
sk@dolby.com
0 Likes
Message 7 of 8

Anonymous
Not applicable
Open the attached file ie zip file and save to a location you can find.
Open a part with inventor and copy and paste the code to a module.
There is word wrap from the ng. Delete the space between B and 2 in both
cases.
put an apostrefe in front of those two line that that are red. now you can
run it.

Patrick !! did I leave something out?

Ole
"-Steve-Krause-" wrote in message
news:3BF0675F.CC6A4ECC@dolby.com...
>
> >
> > Copy and Paste into default.ivb:
> >
> > Public Sub AddSysDateTime()
> >
> > On Error Resume Next
> >
> > 'Check if the active document is a Drawing
> > If ThisApplication.ActiveDocumentType = kDrawingDocumentObject Then
> >
> > 'Add a custom property "SysDate" with system date
> > Set oPropSet =
> >
ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B
> > 2CF9AE}")
> > 'As a workaround the property must be delete if it exist because it
can
> > not be changed
> > oPropSet.Item("SysDate").Delete
> > Call oPropSet.Add(Date, "SysDate")
> >
> > 'Add a custom property "SysTime" with system time
> > Set oPropSet =
> >
ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B
> > 2CF9AE}")
> > 'As a workaround the property must be delete if it exist because it
can
> > not be changed
> > oPropSet.Item("SysTime").Delete
> > Call oPropSet.Add(Format(Time, "hh:mm"), "SysTime")
> >
> > End If
> >
> > End Sub
> >
>
>
>
> I found a default.ivb file in Program files\Autodesk-\Inventor
> 5\Bin\Macros but it appears to be a compiled (nontext) file. Should I
> really copy and paste in to that file?
>
> Steve Krause
> sk@dolby.com
0 Likes
Message 8 of 8

Anonymous
Not applicable
Steve,

 

To add the VBA code start Inventor and select
the menu Tools, Macro, Visual Basic Editor then paste the code into the
Module.

 

To run the code next time just select Tools,
Macro, Macros, find the AddSysDateTime in the dialog and press Run

 

I've add the code again in HTML so hopefully there
is no word wrap.

 

Public Sub AddSysDateTime()

 

    On Error Resume
Next

 

'Check if the active document is a Drawing
If
ThisApplication.ActiveDocumentType = kDrawingDocumentObject Then

 

    'Add a custom property
"SysDate" with system date
    Set oPropSet =
ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
   
'As a workaround the property must be delete if it exist because it can not be
changed
   
oPropSet.Item("SysDate").Delete
    Call oPropSet.Add(Date,
"SysDate")

 

    'Add a custom property
"SysTime" with system time
    Set oPropSet =
ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
   
'As a workaround the property must be delete if it exist because it can not be
changed
   
oPropSet.Item("SysTime").Delete
    Call
oPropSet.Add(Format(Time, "hh:mm"), "SysTime")

 

 End If

 

End Sub

 

>
> >
> >
Copy and Paste into default.ivb:
> >
> > Public Sub
AddSysDateTime()
> >
> >     On Error
Resume Next
> >
> > 'Check if the active document is a
Drawing
> > If ThisApplication.ActiveDocumentType =
kDrawingDocumentObject Then
> >
> >    
'Add a custom property "SysDate" with system date
>
>     Set oPropSet =
> >
ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B
>
> 2CF9AE}")
> >     'As a workaround the
property must be delete if it exist because it can
> > not be
changed
> >    
oPropSet.Item("SysDate").Delete
> >     Call
oPropSet.Add(Date, "SysDate")
> >
> >    
'Add a custom property "SysTime" with system time
>
>     Set oPropSet =
> >
ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B
>
> 2CF9AE}")
> >     'As a workaround the
property must be delete if it exist because it can
> > not be
changed
> >    
oPropSet.Item("SysTime").Delete
> >     Call
oPropSet.Add(Format(Time, "hh:mm"), "SysTime")
> >
> > 
End If
> >
> > End Sub
> >
>
>

>
> I found a default.ivb file in Program
files\Autodesk-\Inventor
> 5\Bin\Macros but it appears to be a compiled
(nontext) file.  Should I
> really copy and paste in to that
file?
>
> Steve Krause
>

href="mailto:sk@dolby.com">sk@dolby.com
0 Likes