Uncheck "Date checked" in a drawing and its main assembly or part

Uncheck "Date checked" in a drawing and its main assembly or part

n_krisch
Enthusiast Enthusiast
649 Views
2 Replies
Message 1 of 3

Uncheck "Date checked" in a drawing and its main assembly or part

n_krisch
Enthusiast
Enthusiast

Hej hej,

 

i am trying in VBA to uncheck the "Date checked" box in the iproperties in a drawing and at the same time in its main assembly or main part.

 I have the following code that works for the active document itself:

    ' Get the active document.
    Dim oDoc As Document
    Set oDoc = ThisApplication.ActiveDocument

    ' Get the PropertySets object.
    Dim oPropSets As PropertySets
    Set oPropSets = oDoc.PropertySets

    ' Get the design tracking property set.
    Dim oPropSet As PropertySet
    'Set oPropSet = oPropSets.Item("Design Tracking Properties")


oPropSets.Item("Design Tracking Properties").Item("Date Checked").Value = "01.01.1601 01:00:00"

 

Now i am trying to get the main assembly or part from the drawing and change it as well, but i cant get it together...

I found this code that seems to point me in the right direction. I don't need to open the main assembly but change the "date checked" property.

Dim oDwgDoc As DrawingDocument
    Set oDwgDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
Dim oDrawingView As DrawingView
Dim oModelDoc As Document

For Each oSheet In oDwgDoc.Sheets
oSheet.Activate
Set oDrawingView = oSheet.DrawingViews.Item(1)
Set oModelDoc = oDrawingView.ReferencedDocumentDescriptor.ReferencedDocument
Call ThisApplication.Documents.Open(oModelDoc.FullDocumentName, True) ' False for invisbly opened
Next

 

Can anyone help me out with this or point me into the right direction?

0 Likes
Accepted solutions (1)
650 Views
2 Replies
Replies (2)
Message 2 of 3

JaneFan
Autodesk
Autodesk
Accepted solution

Added some loop to go over all drawing views in all sheets, the following code only contains the case that setting iProperty of top level of the reference document of the drawing view, but not the occurrences  or sub occurrences of the referenced document if it is an assembly document. There need be some change if you need the function implemented on all level sub occurrences.

 

Sub Entrance()
Dim oDwgDoc As DrawingDocument
Set oDwgDoc = ThisApplication.ActiveDocument

Dim oSheet As Sheet
Dim oDrawingView As DrawingView
Dim oModelDoc As Document

For Each oSheet In oDwgDoc.Sheets
oSheet.Activate
For Each oDrawingView In oSheet.DrawingViews
Set oModelDoc = oDrawingView.ReferencedDocumentDescriptor.ReferencedDocument
ClearDate oModelDoc
Next
Next
End Sub

 

Sub ClearDate(oDoc As Document)
' Get the PropertySets object.
Dim oPropSets As PropertySets
Set oPropSets = oDoc.PropertySets

' Get the design tracking property set.
Dim oPropSet As PropertySet
'Set oPropSet = oPropSets.Item("Design Tracking Properties")

oPropSets.Item("Design Tracking Properties").Item("Date Checked").Value = "01.01.1601 01:00:00"
End Sub




Jane Fan
Inventor/Fusion QA Engineer
Message 3 of 3

n_krisch
Enthusiast
Enthusiast

Hi JaneFan,

 

works perfect! 🙂 Thank you very much!
I just needed the top level - no occurences.

 

I added one line:

 ClearDate oDwgDoc

so it will uncheck the date in the drawing as well.

 

0 Likes