Activating a Positional Representation is dirting assembly

Activating a Positional Representation is dirting assembly

thom-g
Advocate Advocate
855 Views
5 Replies
Message 1 of 6

Activating a Positional Representation is dirting assembly

thom-g
Advocate
Advocate

When a positional representation is activated, the assembly gets dirty.

But why?

Is it a bug in Inventor 2020.3?

 

DirtyBits.png

 

You can use this VBA-code to reproduce the unexpected behaviour:

 

 

Public Sub DemonstrateUnexpectedBehaviour()
    
    MsgBox "This function will demonstrate the unexpected behaviour of positional representations dirting asemblies." + vbCrLf + vbCrLf + "ATTENTION: all opened files will be closed now!!!"
    
    ' Define paths
    Dim pTemp As String
    Dim fPart As String
    Dim fAssembly As String
    pTemp = Environ("TEMP")
    fPart = pTemp + "\part.ipt"
    fAssembly = pTemp + "\assembly.iam"
    
    ' Close all opened documents
    ThisApplication.Documents.CloseAll (False)
    
    ' Remember the original application setting and ensure that prompt for recomputable changes is enabled
    Dim originalSetting As Boolean
    originalSetting = ThisApplication.SaveOptions.PromptSaveForRecomputableChanges
    ThisApplication.SaveOptions.PromptSaveForRecomputableChanges = True
        
    ' Create a new part document, using the default part template.
    Dim oPartDoc As PartDocument
    Set oPartDoc = ThisApplication.Documents.Add(kPartDocumentObject, _
    ThisApplication.FileManager.GetTemplateFile(kPartDocumentObject))
    
    ' Set a reference to the component definition.
    Dim oCompDef As PartComponentDefinition
    Set oCompDef = oPartDoc.ComponentDefinition
    
    ' Create a new sketch on the X-Y work plane.  Since it's being created on
    ' one of the base workplanes we know the orientation it will be created in
    ' and don't need to worry about controlling it.  Because of this we also
    ' know the origin of the sketch plane will be at (0,0,0) in model space.
    Dim oSketch As PlanarSketch
    Set oSketch = oCompDef.Sketches.Add(oCompDef.WorkPlanes(3))
    
    ' Edit the sketch
    oSketch.Edit
    
    ' Set a reference to the transient geometry object.
    Dim oTransGeom As TransientGeometry
    Set oTransGeom = ThisApplication.TransientGeometry
    
    ' Project the origin point onto the sketch
    Dim oOriginSketchPoint As SketchPoint
    Set oOriginSketchPoint = oSketch.AddByProjectingEntity(oCompDef.WorkPoints.Item(1))
    
    ' Create new point for the rectangle
    Dim oRectangleSketchPoint As SketchPoint
    Set oRectangleSketchPoint = oSketch.SketchPoints.Add(oTransGeom.CreatePoint2d(4, 3), False)
    
    ' Draw a 4cm x 3cm rectangle with the corner at (0,0)
    Dim oRectangleLines As SketchEntitiesEnumerator
    Set oRectangleLines = oSketch.SketchLines.AddAsTwoPointRectangle( _
    oOriginSketchPoint, _
    oRectangleSketchPoint)
    
    ' Constraint the sketch
    Dim oDim1 As OffsetDimConstraint
    Set oDim1 = oSketch.DimensionConstraints.AddOffset(oSketch.SketchLines(1), oSketch.SketchLines(3), oTransGeom.CreatePoint2d(5, 2), False, False)
    
    Dim oDim2 As OffsetDimConstraint
    Set oDim2 = oSketch.DimensionConstraints.AddOffset(oSketch.SketchLines(2), oSketch.SketchLines(4), oTransGeom.CreatePoint2d(2, 2), False, False)
        
    ' Create a profile.
    Dim oProfile As Profile
    Set oProfile = oSketch.Profiles.AddForSolid
    
    ' Exit sketch
    oSketch.ExitEdit
    
    ' Create a base extrusion 1cm thick.
    Dim oExtrudeDef As ExtrudeDefinition
    Set oExtrudeDef = oCompDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfile, kJoinOperation)
    Call oExtrudeDef.SetDistanceExtent(1, kNegativeExtentDirection)
    Dim oExtrude As ExtrudeFeature
    Set oExtrude = oCompDef.Features.ExtrudeFeatures.Add(oExtrudeDef)
    
    ' Save the part file
    Call oPartDoc.SaveAs(fPart, False)
    
    ' Create a new assembly document, using the default template.
    Dim oAssemblyDoc As AssemblyDocument
    Set oAssemblyDoc = ThisApplication.Documents.Add(kAssemblyDocumentObject, _
    ThisApplication.FileManager.GetTemplateFile(kAssemblyDocumentObject))
    
    ' Set a reference to the component definition.
    Dim oACompDef As AssemblyComponentDefinition
    Set oACompDef = oAssemblyDoc.ComponentDefinition
    
    Set oMatrix1 = oTransGeom.CreateMatrix
    Set oMatrix2 = oTransGeom.CreateMatrix
    Call oMatrix2.Translation.AddVector(oTransGeom.CreateVector(0, 0, 15))
    
    ' Add the part to the assembly origin
    Dim oPart1 As ComponentOccurrence
    Set oPart1 = oACompDef.Occurrences.AddByComponentDefinition(oCompDef, oMatrix1)
    
    ' Ground the part occurrence 1
    oPart1.Grounded = True
    
    ' Add the part again to the assembly
    Dim oPart2 As ComponentOccurrence
    Set oPart2 = oACompDef.Occurrences.AddByComponentDefinition(oCompDef, oMatrix2)
    
    ' Constraint the part occurrence 2
    Dim oConstraints As AssemblyConstraints
    Set oConstraints = oACompDef.constraints
    
    Dim oPartPlaneProxy As WorkPlaneProxy
    Call oPart2.CreateGeometryProxy(oPart2.Definition.WorkPlanes.Item(1), oPartPlaneProxy)
    Dim oConstraint1 As FlushConstraint
    Set oConstraint1 = oConstraints.AddFlushConstraint(oPartPlaneProxy, oACompDef.WorkPlanes.Item(1), 0)
    
    Call oPart2.CreateGeometryProxy(oPart2.Definition.WorkPlanes.Item(2), oPartPlaneProxy)
    Dim oConstraint2 As FlushConstraint
    Set oConstraint2 = oConstraints.AddFlushConstraint(oPartPlaneProxy, oACompDef.WorkPlanes.Item(2), 0)
    
    Call oPart2.CreateGeometryProxy(oPart2.Definition.WorkPlanes.Item(3), oPartPlaneProxy)
    Dim oConstraint3 As FlushConstraint
    Set oConstraint3 = oConstraints.AddFlushConstraint(oPartPlaneProxy, oACompDef.WorkPlanes.Item(3), 5)
    
    ' Create a positional representation
    Dim oPos As PositionalRepresentation
    Set oPos = oACompDef.RepresentationsManager.PositionalRepresentations.Add("Demo")
    
    ' Activate the new positional representation
    oPos.Activate
    
    ' Override the 3rd constraint
    Call oPos.SetConstraintValueOverride(oConstraint3, 10)
    
    ' Activate the master positional representation
    oACompDef.RepresentationsManager.PositionalRepresentations.Item(1).Activate
    
    ' Save the assembly
    Call oAssemblyDoc.SaveAs(fAssembly, False)
    
    ' Inform the user that the assembly is not dirty at the moment
    MsgBox "Assembly and part are now saved and fully ok." + vbCrLf + vbCrLf + "Assembly is dirty: " + CStr(oAssemblyDoc.Dirty)
    
    ' Activate the new positional representation
    MsgBox "Step 1/2" + vbCrLf + vbCrLf + "Activating Demo positional representation"
    oPos.Activate
    
    ' Activate the master positional representation
    MsgBox "Step 2/2" + vbCrLf + vbCrLf + "Activating Master positional representation"
    oACompDef.RepresentationsManager.PositionalRepresentations.Item(1).Activate
    
    ' Inform the user that the assembly is now dirty
    MsgBox "As if by a miracle, the assembly is now dirty." + vbCrLf + "And the Dirty Bits property has the value 0X10 instead of the expected value 0X0." + vbCrLf + vbCrLf + "But WHY??????" + vbCrLf + vbCrLf + "Assembly is dirty: " + CStr(oAssemblyDoc.Dirty) + vbCrLf + "Inventor version is: " + ThisApplication.SoftwareVersion.DisplayName
    
    ' Restore the original application setting
    ThisApplication.SaveOptions.PromptSaveForRecomputableChanges = originalSetting
    
End Sub

 

 

0 Likes
Accepted solutions (1)
856 Views
5 Replies
Replies (5)
Message 2 of 6

Bert_Bimmel
Advocate
Advocate
It's not a Bug. It's the Autodeskian Uncertainty Principle (watching a system changes the system). It's one of the many ways how the developers of Inventor sabotage the developers of the Vault. Just have a look at this thread:

https://forums.autodesk.com/t5/inventor-ideas/stop-telling-me-i-need-to-save-something-i-haven-t-cha...
😄
Besides: When the geometry of any referenced part has changed, and you are prompted to update the assembly, and you grant this update, only the Master Posrep will be newly computed. All other PosReps remain outdated and prompt for a geometric update later when they are beeing watched or referenced by a PosRep of a parent Assembly (and you have probably already checked it in or even released, and can't save them any more upon the inevitable upcoming save prompt).

Anyway, even if you have urged Inventor to perform the geometric updates of all PosReps by querying them all once before saving your assembly, your described problem persists: As soon as you watch them, the Document is dirtied.

It's just like scrolling down a Word Document, and you will be prompted to save it, because you have watched another page than just the first one... oh, wait! No it doesn't! That's weird! 😜

What makes it even more ridiculous: If you try to save the Assembly when you're in a non-master-PosRep to tag this PosRep as the "last-viewed-PosRep" that shall be displayed first upon next opening of that Assembly, Inventor will tell you, that it can't save the assembly when in "Non-Master-PosRep". Thus, you will have to return to the master PosRep, and Inventor will prompt you to save what has actually changed: The DatabaseRevisionID and the File-Save-Counter... in other words: the two indicators, that the file has been saved AGAIN - and nothing else! |-(

(btw: With LOD's it actually is possible to tag the last active one inside the file to make it the initially active one when reopening the file!)
0 Likes
Message 3 of 6

Cadkunde.nl
Collaborator
Collaborator

Hey @thom-g ,

 

Not that I have anything to add to this topic besides sharing the frustration of inventors need to update.

But I am curious about your first screenshot with the save status window.

 

Is that something you made yourself? Found in the SDK? Or am I missing something in Inventor.

No actual need atm, but it looks really handy for diagnostics

0 Likes
Message 4 of 6

Bert_Bimmel
Advocate
Advocate

Go to "About Inventor" ...

Bert_Bimmel_0-1681895504984.pngBert_Bimmel_1-1681895527209.png

... and then strike control-D

Message 5 of 6

thom-g
Advocate
Advocate
Accepted solution

Update: In 2021 I also created a problem report for this specific issue and this problem report is marked as fixed.

 

@Bert_Bimmel: Thanks for sharing the link to the Inventor idea. Yes, all these things and the ones in your post are one of the main reasons why people get annoyed with Inventor.... But it's still better than AutoCAD where even zooming is a change. 🙄

 

@Cadkunde.nl: To open the "Save Status" popup, first open Inventor's about dialog and then press the CTRL and D keys on your keyboard: >link<

 

By the way, there is another good diagnostic popup to find bad bodies in a part or assembly: >link< 

Message 6 of 6

Cadkunde.nl
Collaborator
Collaborator

Cool, too bad they are so hidden. Diagnostics like that are helpful, I'll remember them

0 Likes