Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations Toost on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Solidworks IJK

Status
Not open for further replies.

bigkadz

Automotive
Apr 3, 2006
4
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!
 
Replies continue below

Recommended for you

Sorry, I'm not familiar with it. What is IJK vector?

Chris
Systems Analyst, I.S.
SolidWorks/PDMWorks 05
AutoCAD 06
ctopher's home site (updated 06-21-05)
FAQ559-1100
FAQ559-716
 
IJK vectors are the cosine values of the X, Y, and Z angles. they provide you with the direction of your vector.
 
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
 
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.

box4vj.jpg
 
rfus,
Please see faq559-1100
Showing pic here doesn't do well within the thread.
thanks.

Chris
Systems Analyst, I.S.
SolidWorks/PDMWorks 05
AutoCAD 06
ctopher's home site (updated 06-21-05)
FAQ559-1100
FAQ559-716
 
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?
 
I would just want to select points
 
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
 
Forgot to mention that this calculates the ijk vector between two preselected vertices.
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor