Get Plane (Front, Top, Right etc) that a sketch was created on

Get Plane (Front, Top, Right etc) that a sketch was created on

isocam
Collaborator Collaborator
903 Views
8 Replies
Message 1 of 9

Get Plane (Front, Top, Right etc) that a sketch was created on

isocam
Collaborator
Collaborator

Can anybody help???

 

Is it possible, for testing purposes only, to use VBA to display in a message box the plane that was used to create a sketch for example, Top, Right Left etc

 

Many thanks in advance!!!!

 

Darren

0 Likes
904 Views
8 Replies
Replies (8)
Message 2 of 9

clutsa
Collaborator
Collaborator

Something like this?

Sub OriginPlaneName()
Dim app As Application
Dim Doc As Document
Set app = ThisApplication
Set Doc = app.ActiveDocument
Dim compDef As ComponentDefinition
Set compDef = Doc.ComponentDefinition
Dim oSketch As Sketch
Set oSketch = app.CommandManager.Pick(SelectionFilterEnum.kSketchObjectFilter, "Select a Sketch:")
MsgBox (oSketch.PlanarEntity.Name)
End Sub
If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

0 Likes
Message 3 of 9

dgreatice
Collaborator
Collaborator

Hi,

 

I think this always use user defined, some people have difference perspective view in inventor, example default template inventor for view cube, when you see view cube in FRONT VIEW, what direct plane you see parallel with FRONT VIEW?,  it XY plane?

 

my perspective view XY plane is a TOP VIEW, so I change my cube setting to TOP VIEW.

another example, because inventor can make multi solid, when you create each solid became a component, I think it will be difference perspective view each component.

 

so when you want define which is TOP VIEW, it will must be user define.

 

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
0 Likes
Message 4 of 9

isocam
Collaborator
Collaborator

Is it possible to change the following line so that it always uses "Sketch1" instead of selecting the sketch manually?

 

Set oSketch = app.CommandManager.Pick(SelectionFilterEnum.kSketchObjectFilter, "Select a Sketch:")

 

Many thanks!!!

 

Darren

0 Likes
Message 5 of 9

dgreatice
Collaborator
Collaborator

Hi,

 

I know to get planar entity, but did you know are there are TOP VIEW or etc?

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
0 Likes
Message 6 of 9

dgreatice
Collaborator
Collaborator

assume,

 

we select Sketch1, and we know planar entity was XY plane, for default Inventor Set it will be Front View, but my perspective view XY plane is TOP View. so User can flexible define which is Front View or etc.

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
0 Likes
Message 7 of 9

clutsa
Collaborator
Collaborator
Sub OriginPlaneName()
Dim app As Application
Dim Doc As Document
Set app = ThisApplication
Set Doc = app.ActiveDocument
Dim compDef As ComponentDefinition
Set compDef = Doc.ComponentDefinition
Dim oSketch As Sketch
Set oSketch = compDef.Sketches.Item("Sketch1")
MsgBox (oSketch.PlanarEntity.Name)
End Sub
If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

0 Likes
Message 8 of 9

clutsa
Collaborator
Collaborator

@dgreatice are you working with @isocam? I'm having a hard time understanding your question but I think you want to display "Top View" ILO "XZ Plane". Can you do...

Sub OriginPlaneName()
Dim app As Application
Dim Doc As Document
Set app = ThisApplication
Set Doc = app.ActiveDocument
Dim compDef As ComponentDefinition
Set compDef = Doc.ComponentDefinition
Dim oSketch As Sketch
Set oSketch = compDef.Sketches.Item("Sketch1")
Dim PlaneName As String
Select Case oSketch.PlanarEntity.Name
Case "XY Plane"
    PlaneName = "Front View"
Case "XZ Plane"
    PlaneName = "Top View"
Case "YZ Plane"
    PlaneName = "Right View"
Case Else
    PlaneName = oSketch.PlanarEntity.Name
End Select
MsgBox (PlaneName)
End Sub
If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

0 Likes
Message 9 of 9

clutsa
Collaborator
Collaborator
Sub OriginPlaneName()
Dim app As Application
Dim Doc As Document
Set app = ThisApplication
Set Doc = app.ActiveDocument
Dim compDef As ComponentDefinition
Set compDef = Doc.ComponentDefinition

Dim oSketch As PlanarSketch
Set oSketch = compDef.Sketches.Item("Sketch1")
Doc.SelectSet.Select oSketch
Dim oControlDef As ControlDefinition
Set oControlDef = app.CommandManager.ControlDefinitions.Item("AppLookAtCmd") 'Look at the sketch
oControlDef.Execute
Dim PlaneName As String
PlaneName = Doc.Views.Item(1).Camera.ViewOrientationType
Select Case PlaneName
Case ViewOrientationTypeEnum.kFrontViewOrientation
    PlaneName = "Front View"
Case ViewOrientationTypeEnum.kTopViewOrientation
    PlaneName = "Top View"
Case ViewOrientationTypeEnum.kRightViewOrientation
    PlaneName = "Right View"
'finish cases for other views
Case Else
    'PlaneName = oSketch.PlanarEntity.Name
End Select
MsgBox (PlaneName)
End Sub

This moves the view but returns the Front, Top, Right based on the view cube settings.

If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

0 Likes