Trying to move a RevisionCloud

Trying to move a RevisionCloud

Anonymous
Not applicable
482 Views
3 Replies
Message 1 of 4

Trying to move a RevisionCloud

Anonymous
Not applicable

It has been nearly 10 years since I wrote code and boy am I feeling rusty:)  

 

Can someone tell me what I am missing here.  The only sketches in this drawing are revision clouds which is what I am trying to be able to move.

 

 

 

    Dim oDoc As DrawingDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oSheet As Sheet
    Set oSheet = oDoc.Sheets(1)
    
    Dim oDwgSketch As DrawingSketch
    Dim oSketchObj As SketchEntity
    Dim oTransGeom As TransientGeometry
    Set oTransGeom = ThisApplication.TransientGeometry
    
    Dim oCollection As ObjectCollection
    Set oCollection = ThisApplication.TransientObjects.CreateObjectCollection()
    
    Dim oVector As Vector2d
    Set oVector = oTransGeom.CreateVector2d(3, 1)

    For Each oDwgSketch In oSheet.Sketches
        If Left(oDwgSketch.Name, 13) = "RevisionCloud" Then
            For Each oSketchObj In oDwgSketch.SketchEntities
                    oCollection.Add oSketchObj
            Next
            
            Call oDwgSketch.MoveSketchObjects(oCollection, oVector)
        
        End If
    Next
0 Likes
Accepted solutions (1)
483 Views
3 Replies
Replies (3)
Message 2 of 4

Jef_E
Collaborator
Collaborator

I think you must move the sketch and what you are trying to do is for moving sketch entities inside a sketch? But I don't know how, API is vague on this... for sketched symbols it's easy..

 

I'm also interested in the solution here.

 

 



Please kudo if this post was helpfull
Please accept as solution if your problem was solved

Inventor 2014 SP2
Message 3 of 4

ekinsb
Alumni
Alumni
Accepted solution

Jeff is correct that ideally you should move the sketch.  That's what's happening when you drag and move a revision cloud in the UI.  Unfortunately the ability to set the position of a sketch was overlooked in the API so that's not currently possible.  However, it is possible to do what you were originally trying and move all of the geometry.  There are a couple of things to be aware of.  First, when getting revision clouds, the sketch can be owned by the sheet or a drawing view.  It depends on where the revision cloud is drawn whether it associates with a view or not.  The second is that you have to set the sketch in edit mode before moving the contents.  Ideally this shouldn't be needed but drawing has a few quirks where this is needed.  Below is an example where it gets a revision cloud on the sheet and one on a view and moves it.

 

Public Sub MoveRevisionCloud()
    Dim oDoc As DrawingDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oSheet As Sheet
    Set oSheet = oDoc.Sheets(1)
    
    ' Find the sketch that represents a revision cloud on the sheet.
    Dim checkSketch As DrawingSketch
    Dim sk As DrawingSketch
'    For Each checkSketch In oSheet.sketches
'        If Left(checkSketch.name, 13) = "RevisionCloud" Then
'            Set sk = checkSketch
'            Exit For
'        End If
'    Next
    
    ' Find the sketch that represents a revision cloud on a view.
    Dim drawView As DrawingView
    For Each drawView In oSheet.DrawingViews
        For Each checkSketch In drawView.sketches
            If Left(checkSketch.name, 13) = "RevisionCloud" Then
                Set sk = checkSketch
                Exit For
            End If
        Next
        If Not sk Is Nothing Then
            Exit For
        End If
    Next
    
    ' Add all of the sketch points into a collection.  All other geometry is
    ' dependent on sketch points so they'll move if the points are moved.
    Dim skPoint As SketchPoint
    Dim pnts As ObjectCollection
    Set pnts = ThisApplication.TransientObjects.CreateObjectCollection
    For Each skPoint In sk.SketchPoints
        Call pnts.Add(skPoint)
    Next
    
    ' Force the sketch into edit mode and move the points.
    sk.Edit
    Call sk.MoveSketchObjects(pnts, ThisApplication.TransientGeometry.CreateVector2d(5, 2), False, False)
    
    ' Exit edit mode.
    sk.ExitEdit
End Sub

Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes
Message 4 of 4

Anonymous
Not applicable

Thanks Brian,

 

As always, I appreciate your help.  In trying to figure it out I had looked at offsetting sketches, and since it said not to pick the points, I figured that was true here also.

 

I have hundreds of drawings we are converting from Imperial to Metric sheet size, and I have automated most of it, except the Revision Clouds.  The only ones I care about are up on the partslists, and with your code I should be able to cobble something together to move those the proper amount also.

 

Thanks again.

0 Likes