inserting a plane at the current view point.

Discussion in 'SolidWorks' started by JF, Apr 1, 2005.

  1. JF

    JF Guest

    Is there a way to extract the coordinates of the current view point
    in order to insert a reference plane?

    For example I need to input a plane at a skewed angle.
    (from the standard 3 orientation)

    Take any part and use the view rotate function to get the
    part into a orientation that is "moldable".

    If I record a macro I get stuff that looks like this:

    Part.ActiveView().RotateAboutCenter 0, 0.013533
    Part.ActiveView().RotateAboutCenter 0, 0.00676651
    Part.ActiveView().RotateAboutCenter 0, 0.00676651
    Part.ActiveView().RotateAboutCenter -0.00497162, 0
    Part.ActiveView().RotateAboutCenter 0, 0.00676651
    End Sub

    How can I use this to define a plane with 3 points?

    Can anybody help me with this?
     
    JF, Apr 1, 2005
    #1
  2. JF

    CS Guest

    I wrote this one a few months ago becuase I required it.

    just paste this into an empty macro

    Sub main()
    'Written by Corey Scheich
    'Creates a plane Parallel with the current view rotation
    'through the origin of the part

    Dim swApp As SldWorks.SldWorks
    Dim Model As SldWorks.ModelDoc2
    Dim ThisView As SldWorks.ModelView
    Dim ViewTransform As SldWorks.MathTransform
    Dim MathUtil As SldWorks.MathUtility
    Dim Point1 As SldWorks.MathPoint
    Dim Point2 As SldWorks.MathPoint
    Dim Point3 As SldWorks.MathPoint
    Dim dPoint(2) As Double
    Dim vPoint As Variant
    Dim NewPlane As SldWorks.refPlane

    Set swApp = Application.SldWorks
    Set Model = swApp.ActiveDoc
    Set ThisView = Model.ActiveView
    Set MathUtil = swApp.GetMathUtility

    dPoint(0) = 0
    dPoint(1) = 0
    dPoint(2) = 0

    vPoint = dPoint

    Set Point1 = MathUtil.CreatePoint((vPoint))
    Point1.ArrayData = vPoint
    dPoint(0) = 1
    dPoint(1) = 0
    dPoint(2) = 0

    vPoint = dPoint

    Set Point2 = MathUtil.CreatePoint((vPoint))

    dPoint(0) = 0
    dPoint(1) = 1
    dPoint(2) = 0

    vPoint = dPoint

    Set Point3 = MathUtil.CreatePoint((vPoint))


    Set ViewTransform = ThisView.Orientation3
    'change from (model to view) to (view to model)
    Set ViewTransform = ViewTransform.Inverse

    'transform the points from View to Model
    Set Point1 = Point1.MultiplyTransform(ViewTransform)
    Set Point2 = Point2.MultiplyTransform(ViewTransform)
    Set Point3 = Point3.MultiplyTransform(ViewTransform)

    'Create a plane through the points
    Set NewPlane = Model.CreatePlaneFixed2( _
    Point1.ArrayData, _
    Point2.ArrayData, _
    Point3.ArrayData, _
    True)
    Model.UnBlankRefGeom

    End Sub
     
    CS, Apr 1, 2005
    #2
  3. JF

    JF Guest

    Cool!

    that works great!
     
    JF, Apr 1, 2005
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.