Rotate sketch geometry.

Rotate sketch geometry.

stuartmp
Advocate Advocate
4,315 Views
9 Replies
Message 1 of 10

Rotate sketch geometry.

stuartmp
Advocate
Advocate

Hi All, I am currently modifying a lot of parts that have alot of sketches in them where the sketckes origin axises are not in the same orientation. I have tried to rotate the sketch geometry including dimensions but the rotate command does not seam to allow the rotation of sketch geometry attached to certain types of dimensions. I have written a macro that removes all the constraints which I have run before I tried to rotate all the sketch geometry including dimensions. Editing the sketch coordinate system does not allow me to get the sketch geometry in the correct orientation this is why I need to use rotate. any help, suggestions or macro would be fantastic. Thanks Stuart.

0 Likes
4,316 Views
9 Replies
Replies (9)
Message 2 of 10

Vladimir.Ananyev
Alumni
Alumni

Normally you should use PlanarSketch.RotateSketchObjects method to rotate sketch entities.  Can RemoveConstraints argument  help you? 

Sketch geometry is based on sketchpoints.  So it is enough to rotate points, all other entities are dependent on them. But you can not rotate grounded entities. These constraints must be deleted.

It is difficult to advice something useful without your sketch sample and used code.

Could you upload some sample?

 

 


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 10

Ralf_Krieg
Advisor
Advisor

Hello

 

If any constraint is removed, all sketch objects should be able to rotate. So I believe that you don't remove all. What about projected entities like work axes? Is the projected constraint removed? Or if this objects are not in the selection that will be rotated, is there a dimension between your sketch objects and this projected entities? If the dimension is not assigned to endpoints but to the lines itself, is implies a parallel constraint even it is not shown explicitly. Both can maybe prevent rotation.


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 4 of 10

stuartmp
Advocate
Advocate

Thanks for the input guys.

 

Below is my macro

 

----------

 

Sub RotateSketch()

Dim oApp As Inventor.Application
Set oApp = ThisApplication

Dim oDoc As Document
Set oDoc = oApp.ActiveDocument

Dim oTxnMgr As TransactionManager
Set oTxnMgr = ThisApplication.TransactionManager
   
' Start a transaction
Dim oTxn1 As Transaction
Set oTxn1 = oTxnMgr.StartTransaction(oDoc, "MyRotateSketchMacro")

Dim oActvieSketch As PlanarSketch

If oDoc.ActivatedObject.Type = kPlanarSketchObject Then
    Set oActvieSketch = oDoc.ActivatedObject
Else
    MsgBox "Please exit the sketch you wish to rotate the geomerty on then re-run the macro", vbCritical
    Exit Sub
End If

Dim oSketchObjects As Inventor.ObjectCollection
Set oSketchObjects = oApp.TransientObjects.CreateObjectCollection


Dim oSketchEntity As SketchEntity
Dim SketchConstraints As SketchConstraintsEnumerator
Dim SketchConstraint As Variant

For Each oSketchEntity In oActvieSketch.SketchEntities

    Set SketchConstraints = oSketchEntity.Constraints
        
        For Each SketchConstraint In SketchConstraints
            
            If SketchConstraint.Type <> kTwoPointDistanceDimConstraintObject And _
            SketchConstraint.Type <> kOffsetDimConstraintObject And _
            SketchConstraint.Type <> kDiameterDimConstraintObject And _
            SketchConstraint.Type <> kRadiusDimConstraintObject _
            Then
            
                If SketchConstraint.Type = kGroundConstraintObject And SketchConstraint.Deletable = True Then
                    On Error Resume Next
                    SketchConstraint.Delete
                End If
            End If
        Next
        
    oSketchObjects.Add oSketchEntity
Next

' Set a reference to the transient geometry collection.
Dim oTransGeom As TransientGeometry
Set oTransGeom = ThisApplication.TransientGeometry
 
Dim oPoint As Point2d
Set oPoint = oTransGeom.CreatePoint2d(0, 0)
 
 
Dim dDeg As Double
dDeg = InputBox("Enter Angle to Rotate", "RotateSketch", 270)

Dim dPi As Double
dPi = dDeg * Atn(1)

Call oActvieSketch.RotateSketchObjects(oSketchObjects, oPoint, dPi, False, True)

oTxn1.End


End Sub

 

------------------

 

I have attached two sketches (Inventor 2013 format).

 

One that will rotate and one that will not rotate using the macro.

 

If you could help me work out why the one of them will not rotate that would be fantastic.

 

Thanks

 

Stuart

 

 

Message 5 of 10

ekinsb
Alumni
Alumni

It's not an API issue but an Inventor limitation.  You see the same result when rotating the sketch interactively.  The problem is the dimensions to the sketch points you've created at the midpoint of some of the lines.  There isn't a way to create many of these when the sketch is rotated.  Inventor should probably be removing these since they're blocking the rotate, but currently it does not.  You might be able to add a check for linear dimenstions to a sketch point that is constrained to the center of a line and delete them. If you do that, your final sketch will be missing quite of bit of the original definition.

 

Why can't you edit the sketch coordinate system to reposition it?  This would allow you to retain all of the constraints.


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

stuartmp
Advocate
Advocate

Hi Brian,

 

Thanks for the response,I will investigate what you have said.

 

Do you think the ability to do this maybe fix in Inventor 2014?

 

The reason I do not want to edit the sketch coordinate system I am trying to rotate the sketch geometry to be in the correct orientation relative to the XY Plane.

 

This will then allow me to copy geometry between sketches in the same part and the sketch geometry will be in the same location.

 

....

 

Brian do you have a e-mail address I can e-mail you directly?

 

 

Thanks again for commenting on this topic.

 

Stuart

 

 

0 Likes
Message 7 of 10

xiaodong_liang
Autodesk Support
Autodesk Support

Hi,

 

Sorry, we have not the information about release 2014 for public right now. If you are ADN member, please log in ADN site and get the material of DevDays we held recently to see if the information contains what you are interested in.

0 Likes
Message 8 of 10

bravaiser
Enthusiast
Enthusiast

I am having a similar problem where I want to rotate only one object at the time in this case is a ellipse, how can I do that 

 

  oSketch.SketchEllipses.Add(oPoint2d, oUniVector, EigenSize[i].d1/1.25, EigenSize[i].d2/1.25 );

 I want to rotate the previous sketch by 45 degrees how do I make it work?

 

 

0 Likes
Message 9 of 10

Anonymous
Not applicable

Hi I was also having this rotate issue but the fix that I did was to make the sketch a block, then you can rotate it, then explode the block and retain all the dimensions.  Hope this help other users!

Message 10 of 10

Anonymous
Not applicable

That was the trick I needed! Thanks!! 

0 Likes