Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Custom property type date with blank date

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Arnold82
793 Views, 3 Replies

Custom property type date with blank date

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

3 REPLIES 3
Message 2 of 4
xiaodong_liang
in reply to: Arnold82

Hi,

 

please give it a try with

 

Imports System

Dim nullDate As Nullable 
iProperties.Value("Custom", "aaa") = nullDate
Message 3 of 4
Arnold82
in reply to: Arnold82

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
Majcc
in reply to: Arnold82

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.

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

Post to forums  

Autodesk Design & Make Report