Adding WorkPlane By Using AddByTwoPlanes in Part Environment

Adding WorkPlane By Using AddByTwoPlanes in Part Environment

KKizildemir
Collaborator Collaborator
1,232 Views
6 Replies
Message 1 of 7

Adding WorkPlane By Using AddByTwoPlanes in Part Environment

KKizildemir
Collaborator
Collaborator

Hi everyone,

 

I am trying to add a work plane by using 'AddByTwoPlanes' method in the part environment. Here is VBA code:

Sub CreateWP()
    Dim oPartDoc As PartDocument
    Set oPartDoc = ThisApplication.ActiveDocument

    Dim oPartCD As PartComponentDefinition
    Set oPartCD = oPartDoc.ComponentDefinition

    Dim WP1 As WorkPlane
    Set WP1 = oPartCD.WorkPlanes.Item(1)
    
    Dim WP2 As WorkPlane
    Set WP2 = oPartCD.WorkPlanes.Item(2)
      
    Dim oWPlane As WorkPlane
    Set oWPlane = oPartCD.WorkPlanes.AddByTwoPlanes(WP1, WP2)
End Sub

 

All the other work plane adding methods are working but unfortunately I am not able to use this method. When I run the code, oWPlane returns nothing after a run-time error.

 

Any comments on this?

 

Thanks!

Signature

website
emailskypelinkedinyoutubeemail
0 Likes
Accepted solutions (2)
1,233 Views
6 Replies
Replies (6)
Message 2 of 7

Michael.Navara
Advisor
Advisor

This is because work planes are perpendicular.  WorkPlanes(1) is YZ and WorkPlanes(2) is XZ. In this case the third argument QuadrantPoint is required. 

See API documentation of this function for more information

Message 3 of 7

clutsa
Collaborator
Collaborator

Can you give an example of creating a quadrantpoint? I don't see it in the object browser and the function help text simply calls it [QuadrantPoint] not "as" any other object type.

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 4 of 7

Michael.Navara
Advisor
Advisor
Accepted solution

Here is the final code

 

Sub CreateWP()
    Dim oPartDoc As PartDocument
    Set oPartDoc = ThisApplication.ActiveDocument

    Dim oPartCD As PartComponentDefinition
    Set oPartCD = oPartDoc.ComponentDefinition

    Dim WP1 As WorkPlane
    Set WP1 = oPartCD.WorkPlanes.Item(1)
    
    Dim WP2 As WorkPlane
    Set WP2 = oPartCD.WorkPlanes.Item(2)
    
    Dim oQuadrantPoint As Point
    
    'WorkPlane to quadrants 1-3
    'Set oQuadrantPoint = ThisApplication.TransientGeometry.CreatePoint(1, 1, 0)
    
    'WorkPlane to quadrants 2-4
    Set oQuadrantPoint = ThisApplication.TransientGeometry.CreatePoint(-1, 1, 0)
 
    Dim oWPlane As WorkPlane
    Set oWPlane = oPartCD.WorkPlanes.AddByTwoPlanes(WP1, WP2, oQuadrantPoint)
End Sub
Message 5 of 7

KKizildemir
Collaborator
Collaborator

Thanks @Michael.Navara , it works for me.

 

But I really don't understand what the quadrant point is. Can you please give more information about this?

Signature

website
emailskypelinkedinyoutubeemail
0 Likes
Message 6 of 7

Michael.Navara
Advisor
Advisor
Accepted solution

Quadrant point specifies concrete result for given inputs when multiple solutions is possible.

 

2020-10-05_22-13-49.png

Message 7 of 7

KKizildemir
Collaborator
Collaborator

Great explanation, thank you. It's all clear now.

 

Kind regards!

Signature

website
emailskypelinkedinyoutubeemail
0 Likes