Custom property type date with blank date

Custom property type date with blank date

Anonymous
Not applicable
1,245 Views
3 Replies
Message 1 of 4

Custom property type date with blank date

Anonymous
Not applicable

Hi all,

 

My company has a custom property named 'Released date, Type Date.

This date is still empty

 

I am working on a rule that adds all the custom properties required for the company title block.

This rule can be useful whenever you get a model from a supplier.

 

I can add a custom property date using the following code:

 

 

Dim oDoc As Document = ThisApplication.ActiveDocument
Dim customPropertySet As PropertySet = oDoc.PropertySets.Item("Inventor User Defined Properties")

Try

iProperties.Value("Custom", "Released Date") = iProperties.Value("Custom", "Released Date")
Catch

Dim DateValue As Date = Now 'System.DBNull.Value
customPropSet.Add(DateValue, "Released Date")
End Try

 

This code works but sets the released date to Now.

But the release date needs to remain blank when adding.

 

I tried to make the value Null but I get the error:

"Value of type 'System.DBNull' cannot be converted to 'Date'."

 

Is there a way to keep a custom property date blank?

 

 

Thx in advance,

 

Arnold

0 Likes
Accepted solutions (1)
1,246 Views
3 Replies
Replies (3)
Message 2 of 4

xiaodong_liang
Autodesk Support
Autodesk Support
Accepted solution

Hi,

 

please give it a try with

 

Imports System

Dim nullDate As Nullable 
iProperties.Value("Custom", "aaa") = nullDate
Message 3 of 4

Anonymous
Not applicable

Works!

I had to add it accordingly (first create date, then make it nulldate):

 

Dim customPropertySet As PropertySet = oDoc.PropertySets.Item("Inventor User Defined Properties")
DimDateValueAsDate=Now
customPropertySet.Add(DateValue, "Released Date")
Dim nullDate As Nullable
iProperties.Value("Custom", "Released Date") = nullDate

 

Thanks!

 

Message 4 of 4

Anonymous
Not applicable

Hi,

 

I would like to create an external rule, wich can be setted some parameter.

I have some problem with date variable.

I use the following code:

   Dim nullDate As Nullable

   iProperties.Value("Custom", "04. Szállítási határidő - T")=nullDate

After I run this rule the Type of properties stay Text and do not Date format. The Value of properties changes to blank.


I tried the following code:
   iProperties.Value("Custom", "04. Szállítási határidő - T")=CDate("nullDate")

This code can not work.

I attach a picture, where you can see what I want to get.

0 Likes