Just show the sketches in your assembly, pick the points and measure.
Thanks for your reply.
I am not sure if I was clear in my question.
I want to create a macro that does every thing automatically; Opens the assembly that contains four parts and measure the distance between the points located in a 3d sketch in each part.
I think first I am going to go with what Viktor suggested.
Thank you for your reply
Your approach is right. This is a good way of automating the measurement of the distance between 2 points. However, you do not need to open each part individually and need to use Z coordinate in distance formula as well.
As a result, your plan should look like this:
- Open the assembly file and get the transformation matrix for each component (MathTransform = IComponent2.Transform2)
- Traverse assembly and get needed sketches from all parts in assembly; get coordinates of the point relative to the part model. Create mathPoint from them (IMathPoint = IMathUtility.CreatePoint(ArrayDataIn))
- apply the transformation to the point and get the coordinates of the points in the assembly model (IMathPoint = IMathPoint.MultiplyTransform(MathTransform))
- measure the distance using the distance formula sqrt( (x2-x1)^2+(y2-y1)^2 + (z2-z1)^2)
Thanks Viktor for your reply and suggestions.
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Set swApp = GetObject(, "SldWorks.Application")
Set swModel = swApp.ActiveDoc
''Insert method for selecting parts"
Set Measure = swModel.Extension.CreateMeasure
variable = Measure.(there are a number of different members such as distance, deltaX, deltaY, and deltaZ....)