iLogic rotate Part

iLogic rotate Part

Anonymous
Not applicable
2,735 Views
7 Replies
Message 1 of 8

iLogic rotate Part

Anonymous
Not applicable

I've been using iLogic to create a Shrinkwrap of an assembly. The problem I'm having is it resets the current view. I need to rotate the Part (Which is a new Part Document) 90° to the right.

 

I found and have been trying a bit with this:

 

  Const PI = 3.14159265358979
  
  Dim d As Inventor.PartDocument
  d = ThisApplication.ActiveDocument
 

  Dim a As WorkAxis
  
  a = d.ComponentDefinition.WorkAxes(1)
 
  Dim o As Inventor.ComponentDefinition
  o = d.ComponentDefinition


  Dim t As TransientGeometry
  t = ThisApplication.TransientGeometry
     
  Dim l As Line
  l = a.Line
  
  Dim mRot As Matrix
  mRot = t.CreateMatrix()
  ' PI / 2 => 90 deg
  mRot.SetToRotation(PI / 2, l.Direction.AsVector(), l.RootPoint)
  
  Dim m As Matrix
  m = o.Transformation

  MessageBox.Show("Message", "Title")
  m.PreMultiplyBy(mRot)
  
  o.Transformation = m
0 Likes
Accepted solutions (1)
2,736 Views
7 Replies
Replies (7)
Message 2 of 8

fullevent
Advisor
Advisor

Hello @Anonymous 

 

I may not understand what you want exactly, but you can only reorient a sub-assembly or part within an assembly.

 

A part has no orientation / matrix..

 


@Anonymous  schrieb:

 

  Const PI = 3.14159265358979
  
  Dim d As Inventor.PartDocument
  d = ThisApplication.ActiveDocument
 

  Dim a As WorkAxis
  
  a = d.ComponentDefinition.WorkAxes(1)
 
  Dim o As Inventor.ComponentDefinition
  o = d.ComponentDefinition
...
  Dim m As Matrix
  m = o.Transformation

  ...

The red line should not be possible.

 

Can you make a few screenshots or a screencast to explain us your request in detail?


Aleksandar Krstic
Produkt- und Projektmanager

0 Likes
Message 3 of 8

Anonymous
Not applicable

Thanks for your reply. I'm trying to rotate the part 90 degrees. In the first image the part is shrinkwrapped, when it's shrinkwrapped it changes the current view. The second one shows how the current view is supposed to be.

 

I'm trying to do this by iLogic because of automation reasons.

0 Likes
Message 4 of 8

fullevent
Advisor
Advisor

Basically you want to reorient the solid, right? I've never realized that before. Unfortunately I do not know how this should work or if it is even that easy to do.

 

But the problem you will have is the following.
Suppose you put the part into many assemblies. Later you change the orientation of the solid body within the IPT.
Then none of your previously created assemblies will fit because the part is suddenly aligned differently.

 

It would be better to reorient the part within the assembly in which it is placed.

Would that be a possible solution for you?


Aleksandar Krstic
Produkt- und Projektmanager

0 Likes
Message 5 of 8

fullevent
Advisor
Advisor
Accepted solution

Take a look on the solution of this german post.

https://forums.autodesk.com/t5/inventor-deutsch/problem-mit-putmatrixdata/m-p/9315531#M17696 

 

You can run the iLogic to rotate a selected component within an assembly by entering the angle values.


Aleksandar Krstic
Produkt- und Projektmanager

0 Likes
Message 6 of 8

Anonymous
Not applicable

Ah thanks! I'll tingle around with it later. My part isn't an assembly though, it's a simple part file. Any idea on how to select the component?

0 Likes
Message 7 of 8

fullevent
Advisor
Advisor

You're welcome.

Nope, it will not work within a partdocument. It must be an assemblydocument.

 


Aleksandar Krstic
Produkt- und Projektmanager

0 Likes
Message 8 of 8

WCrihfield
Mentor
Mentor

Since you are dealing with a Part, perhaps something like the following would work for you.

Dim oDoc As PartDocument = ThisApplication.ActiveDocument
Dim oDef As PartComponentDefinition = oDoc.ComponentDefinition
'Dim oBody As SurfaceBody = oDef.SurfaceBodies.Item(1)
Dim oBody As SurfaceBody = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartBodyFilter, "Select a Part Body.")
Dim oMoveFeatDef As MoveDefinition = oDef.Features.MoveFeatures.CreateMoveDefinition(oBody)
Dim oAxis As WorkAxis = oDef.WorkAxes.Item(1)
oMoveFeatDef.AddRotateAboutAxis(oAxis, False, "90 deg")
Dim oMoveFeat As MoveFeature = oDef.Features.MoveFeatures.Add(oMoveFeatDef)
oMoveFeat.Name = "Rotate " & oBody.Name & " About " & oAxis.Name & " By 90 degrees"

It uses the MoveBody command, but instead of a linear move, it uses the not-so-obvious option (normally hidden within the drop-down) of rotation.  This assumes it is all one body, and not several solid bodies. 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)