INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Eng-Tips
*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Solidworks IJK

Solidworks IJK

(OP)
I was wondering if it is possible for Solidworks to give you an IJK vector, I haven't been able to find any info on this matter, perhaps there is a macro made or something.  Help would be much appreciated!

RE: Solidworks IJK

(OP)
IJK vectors are the cosine values of the X, Y, and Z angles.  they provide you with the direction of your vector.

RE: Solidworks IJK

Lets say your vector is line from a point at the origin (0,0,0) to some value (x,y,z). The length of this line would be the magnitude of the vector. You want the direction of this line in each reference plane, or the projection of this line into a reference plane. You could just open a sketch in each reference plane and convert the line entity into each plane and smart dimension this from a horizontal or vertical center line to obtain your cosines. Or you could create a 3d sketch and do this all in one sketch using your tab key to change reference planes. Do you want to get outputs or compute dot and cross products on line entities in space.

I'd put my vectors into mathcad and take the eigen values of the vector to get its pricipals.

RFUS

RE: Solidworks IJK

(OP)
I need to get outputs

RE: Solidworks IJK

So then, essentially, all you are looking to do is dimension a box with centerlines drawn on faces accross three planes. Make a box that your vector streatches accross, Sketch a centerline on the three views TOP, LEFT, FRONT, and then insert these views into a drawing. Dimension the three views and link these to a table.

RE: Solidworks IJK

This is easy with the API, but the contents of the routine would depend on how flexible you need it to be.  For example, will you preselect the points, or do you also want to be able to select an edge/sketch entity/curve as well?  

RE: Solidworks IJK

(OP)
I would just want to select points

RE: Solidworks IJK

This will get you started.  It will present the results in a message box and also will copy them to the clipboard so you can just paste into the target application.

Copying data to the windows clipboard makes use of the DataObject  variable type.  You must have a reference set in your VBA project to the Microsoft Forms 2.0 object library (under tools, references).

You can expand this to also work with other input yourself (sketch points, reference points etc).  I have not included any error checking.


CODE

Option Explicit

Sub Main()

    Dim swApp           As SldWorks.SldWorks
    Dim swModel         As SldWorks.ModelDoc2
    Dim swSelMgr        As SldWorks.SelectionMgr
    Dim swVertex1       As SldWorks.Vertex
    Dim swVertex2       As SldWorks.Vertex
    Dim DataObj         As New DataObject
    
    Dim vPt1            As Variant
    Dim vPt2            As Variant
    Dim PointDist       As Double
    Dim i               As Double
    Dim j               As Double
    Dim k               As Double
    Dim Msg             As String
    Dim LongStatus      As Long
    
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    
    Set swSelMgr = swModel.SelectionManager
    If Not (swSelMgr.GetSelectedObjectCount = 2) Then
        Msg = "Select two vertices to calculate the IJK vectors"
        LongStatus = swApp.SendMsgToUser2(Msg, swMbWarning, swMbOk)
        End
    End If
    
    Set swVertex1 = swSelMgr.GetSelectedObject6(1, -1)
    vPt1 = swVertex1.GetPoint
    
    Set swVertex2 = swSelMgr.GetSelectedObject6(2, -1)
    vPt2 = swVertex2.GetPoint
    
    PointDist = Sqr((vPt2(0) - vPt1(0)) ^ 2 + (vPt2(1) - vPt1(1)) ^ 2 + (vPt2(2) - vPt1(2)) ^ 2)
    
    Msg = "i = " & (vPt2(0) - vPt1(0)) / PointDist & Chr(13)
    Msg = Msg & "j = " & (vPt2(1) - vPt1(1)) / PointDist & Chr(13)
    Msg = Msg & "k = " & (vPt2(2) - vPt1(2)) / PointDist
    DataObj.SetText Msg
    DataObj.PutInClipboard
    LongStatus = swApp.SendMsgToUser2(Msg, swMbWarning, swMbOk)
    
End Sub

RE: Solidworks IJK

Forgot to mention that this calculates the ijk vector between two preselected vertices.

RE: Solidworks IJK

Nice macro Stoker.

Another noteable: FAQ559-1040

Export your points using this and then just use them with an equation in excel where your i j and k could each be solved in their own cell.

If; v=(x-x0)i + (y-y0)j + (z-z0)k

and magnitude = SQRT((x-x0)^2 + (y-y0)^2 + (z-z0)^2)

a= (x-x0)/SQRT((x-x0)^2 + (y-y0)^2 + (z-z0)^2)
b= (y-y0)/SQRT((x-x0)^2 + (y-y0)^2 + (z-z0)^2)
c= (z-z0)/SQRT((x-x0)^2 + (y-y0)^2 + (z-z0)^2)

Vijk = ai + bj + ck

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close