iPropertie status Checked date CheckBox

iPropertie status Checked date CheckBox

humbertogo
Advocate Advocate
1,665 Views
6 Replies
Message 1 of 7

iPropertie status Checked date CheckBox

humbertogo
Advocate
Advocate

How to

checked the checkbox of the iPropertie Checked date using .NET

 

Thanks

0 Likes
Accepted solutions (2)
1,666 Views
6 Replies
Replies (6)
Message 2 of 7

wayne.brill
Collaborator
Collaborator

Hi,

 

I used the VBA watch window and I see that when the "Checked Date" is not checked the Expression property of the iProperty is an empty string and when it is checked it has a value. Here is the VBA code that makes the expression a date and after running the code I see the property is then checked.

 

Public Sub iProperties_Test()
    ' Get the active document.
    Dim invDoc As Document
    Set invDoc = ThisApplication.ActiveDocument
    
     
    ' Get the design tracking property set.
    Dim invDesignInfo As PropertySet
    Set invDesignInfo = invDoc.PropertySets.Item("Design Tracking Properties")
    
  
    Dim iProp As Property
    For Each iProp In invDesignInfo
        Debug.Print iProp.Value
        If iProp.Name = "Date Checked" Then
            Debug.Print iProp.Value
            iProp.Expression = "6/23/2016"
            Exit For
        End If
    Next iProp
    
End Sub

 

 

Thanks,

Wayne



Wayne Brill
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 7

nmunro
Collaborator
Collaborator

Date properties in Inventor are a bit weird. As Wayne showed you can set the expression to a blank string, but you can also accomplish the same thing by setting the date to a default value; January 1st, 1601.

 

 

        


https://c3mcad.com

0 Likes
Message 4 of 7

humbertogo
Advocate
Advocate

Thanks Wayne for the reply

when I try to set the expression  in a empty string or uncheck the checkbox get a error

0 Likes
Message 5 of 7

nmunro
Collaborator
Collaborator
Accepted solution

You are correct, setting the expression to a blank string does cause an issue. You can try following in VB.NET (I assume that is what you are using). This assumes you have the appropriate Inventor property assigned to the variable prop.

 

 

' create a date variable and set it to the default date of Jan 01, 1601
Dim newDate As Date = New Date(1601, 1, 1)
' assign the date the property value
prop.Value = newDate
'or set the expression
prop.Expression = newDate.ToShortDateString()

 

If you examine the property after doing this you will see the value set to the default date but the expression will be a blank string.

 

If you are assigning a specific date to the property it is better to create the date and assign that to the property value, as trying to work with date strings can be problematic since the date format can change from computer to computer.

        


https://c3mcad.com

Message 6 of 7

humbertogo
Advocate
Advocate
Accepted solution

Thanks

 

PropertySets.Item("{32853F0F-3444-11D1-9E93-0060B03C1CA6}").ItemByPropId(PropertiesForDesignTrackingPropertiesEnum.kDateCheckedDesignTrackingProperties).Expression = newDate.ToShortDateString

0 Likes
Message 7 of 7

Ray_Feiler
Advisor
Advisor

For some reason this didn't work for me, but this code works for my needs. If the check box is not checked then the current date is used as the value.

ReadOnly _PropSets As PropertySets

' Checked Date checkbox
If _PropSets.Item("{32853F0F-3444-11d1-9E93-0060B03C1CA6}").ItemByPropId(PropertiesForDesignTrackingPropertiesEnum.kDateCheckedDesignTrackingProperties).Value = #1/1/1601# Then
_PropSets.Item("{32853F0F-3444-11d1-9E93-0060B03C1CA6}").ItemByPropId(PropertiesForDesignTrackingPropertiesEnum.kDateCheckedDesignTrackingProperties).Value = Date.Now()
End If


Product Design & Manufacturing Collection 2024
Sometimes you just need a good old reboot.
0 Likes