How to force a Drawing to update

How to force a Drawing to update

ACEDeSmedt
Advocate Advocate
2,241 Views
5 Replies
Message 1 of 6

How to force a Drawing to update

ACEDeSmedt
Advocate
Advocate

Is there a way to force a drawing to update?

 

In some situations, I use VBA Scripts to edit some things in the parts that are on a drawing. Sometimes, those edits don't come trough to the drawing itself. Is there a way to force the drawing to update? Like in an assembly, if such things happen, I Use rebuild All to force an update.

 

And yes, I already tried ThisApplication.ActiveDocument.Update

I even tried Looping trough the sheets and the drawing views, all with the update command and still no succes.

 

regards,

Klaas De Smedt

=================================
If this is the solution, push the solution button 😉 (and maybe some kudos)
Autodesk Product Design Suit - Ultimate edition (Subscription)
0 Likes
2,242 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable

Perhaps this VBA program can help you:

 

Public Sub AutoSave_View_Scale()

    Call ShowFirstViewScale
       
    Dim oDrawDoc As Inventor.DrawingDocument
   
    Set oDrawDoc = ThisApplication.ActiveDocument
      
    Set oDoc = Nothing
    Set oDrawDoc = Nothing

End Sub

 


Public Sub ShowFirstViewScale()

    Dim oDrawDoc As Inventor.DrawingDocument
    Set oDrawDoc = ThisApplication.ActiveDocument
    Dim ScaleProp As String
   
    On Error Resume Next
 
    'Find the Scale of the first View on the first Sheet
    ScaleProp = ConvScale(oDrawDoc.Sheets.Item(1).DrawingViews.Item(1).Scale)
   
    'Add a custom property "Scale" with all the view scales
    Dim oPropSet As PropertySet
   
    Set oPropSet = ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
    Call oPropSet.Item("Echelle").Delete
    Call oPropSet.Add(ScaleProp, "Echelle")
   
    'Still having some problems that the last property does not update correct
    Call RefreshProperties


End Sub


Function ConvScale(ValScale As Double) As String

If ValScale >= 1 Then
    ConvScale = CStr(ValScale) + ":1"
Else
    ConvScale = "1:" + CStr(1 / ValScale)
End If

End Function


Private Sub RefreshProperties()
   
    Set oPropSet = ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
    Call oPropSet.Add("", "MyDummy")
    oPropSet.Item("MyDummy").Delete

End Sub

0 Likes
Message 3 of 6

ACEDeSmedt
Advocate
Advocate

Maximus,

 

From your code I remember that you create a dummy property and then delete it forcing the properties to be out of date.

 

My workaround now is to find the first drawingview on the sheet, then find the document, in this document I remove the part number and then I put it back the way it was, forcing the properties of the part/assembly to be out of date.

 

If you want the code for that, I can look it up and post it here.

 

regards,

Klaas De Smedt

=================================
If this is the solution, push the solution button 😉 (and maybe some kudos)
Autodesk Product Design Suit - Ultimate edition (Subscription)
0 Likes
Message 4 of 6

Anonymous
Not applicable

This small program take the "description" and the "title" of the 3D model (part or assembly) and write these fields in the title block of the 2D drawing.

 

Sub AutoSaveUpdateProperty()

    Dim drawDoc As DrawingDocument
    Set drawDoc = ThisApplication.ActiveDocument
   
    'Comme les proprietes "Description" et "Title" existent dans la source (3D) et chez le destinataire (2D), il suffit seulement de donner les concordances
    'Attention: Les proprietes sont contenues dans une patie de l'item : "Item(nombre designant la partie contenant la proprietes desiree)"
    drawDoc.PropertySets.Item(3).Item("Description").Value = drawDoc.Sheets.Item(1).DrawingViews.Item(1).ReferencedDocumentDescriptor.ReferencedDocument.PropertySets.Item(3).Item("Description").Value
    drawDoc.PropertySets.Item(1).Item("Title").Value = drawDoc.Sheets.Item(1).DrawingViews.Item(1).ReferencedDocumentDescriptor.ReferencedDocument.PropertySets.Item(1).Item("Title").Value
   
    Dim invProp As Inventor.Property
    Dim strSourcePropVal As String
   
    'Pour les proprietes rajoutees manuellement, il faut faire un test pour savoir si la propriete de destination existe
    On Error Resume Next
    For Each invProp In drawDoc.Sheets.Item(1).DrawingViews.Item(1).ReferencedDocumentDescriptor.ReferencedDocument.PropertySets.Item(4)
        drawDoc.PropertySets.Item(4).Item(invProp.Name).Value = invProp.Value
        If Err Then
            Err.Clear
            Call drawDoc.PropertySets.Item(4).Add(invProp.Value, invProp.Name)
        End If
    Next

End Sub

0 Likes
Message 5 of 6

ACEDeSmedt
Advocate
Advocate

You can also link the text in the title-block to the iProperties of the part itself. (like I Part number and description)

=================================
If this is the solution, push the solution button 😉 (and maybe some kudos)
Autodesk Product Design Suit - Ultimate edition (Subscription)
0 Likes
Message 6 of 6

Anonymous
Not applicable

Hi ACEDeSmedt,

 

The problem with this software is that the scale in the title block is the scale of the first view OF THE FIRST SHEET. I explain, if in the fisrst sheet, the first view has the scale 1:2, in the title block of the first sheet you see "Scale: 1:2". If in the second sheet, the first view of this one has the scale 1:5, in the title block of the second sheet you see "Scale: 1:2". If you have a solution for this, do not hesitate Smiley Happy.

 

Best regards,

MaX

0 Likes