Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

HOW TO GET POSITION AND ROTATION VALUES

Status
Not open for further replies.

suleymanyaman

Industrial
Jul 30, 2013
29
SE
Hi, I want to get position values and rotation values which belongs interfaces by creating macro?CAn you give me any idea?Thank you.
 
Replies continue below

Recommended for you

I glanced at this link but in here if I am not wrong,user enter into some values and user sets or changes rotation values.How ever I would like to get values automaticly.I add an image file.And also I want to get this values.I am appraciate for helping.
 
 http://files.engineering.com/getfile.aspx?folder=b0f49561-a6f7-4b1f-a7f8-18b9b534f190&file=translate_rotate.bmp
Do you want to measure distance and angle between two objects ?
 
Actually,I want to measure an interface coordinates or position values(X,Y,Z,ROTX,RotY,RotZ) from world zero.
 
For example, I found my part's volume and mass thanks to below codes.And also ı want to figure out position (x,y,z,rotx,roty,rotz) by like these codes.Is it possible?Thanks a lot now.

MsgBox "Part Volume: " &MyProduct.Analyze.Volume
MsgBox "Part Mass: " &MyProduct.Analyze.Mass

Option Explicit

Dim strSearch As String
Dim PartFound As Boolean
'Dim MySelection As Selection

Sub CATMain()

Dim MyDoc As Document
Dim MyProduct As Product

Set MyDoc = CATIA.ActiveDocument
Set MyProduct = MyDoc.Product
'Set MySelection = MyDoc.Selection

strSearch = InputBox("Input Search String")
PartFound = False

If strSearch = "" Then
MsgBox "Search String is Empty", vbExclamation, "Error"
End
End If

Call Traverse(MyProduct)

If PartFound = True Then
MsgBox "Part Found", vbInformation, "Success"
Else
MsgBox "Part Not Found", vbExclamation, "Fail"
End If

End Sub

Sub Traverse(MyProduct As Product)

Dim i As Integer
Dim PartName As String

If PartFound = True Then
Exit Sub
End If

For i = 1 To MyProduct.Products.Count

If MyProduct.Products.Item(i).Products.Count = 0 Then

PartName = MyProduct.Products.Item(i).ReferenceProduct.Parent.Name

If PartName = strSearch Then

PartFound = True

Dim MySelection As Selection
Set MySelection = MyProduct.Parent.Selection

MySelection.Clear
MySelection.Add MyProduct.Products.Item(i)

CATIA.StartCommand "center graph"
CATIA.StartCommand "reframe on"
MsgBox "Part Volume: " &MyProduct.Analyze.Volume
MsgBox "Part Mass: " &MyProduct.Analyze.Mass


End If

Else

Call Traverse(MyProduct.Products.Item(i).ReferenceProduct)

End If

Next

End Sub
 
Actually I am not able to find the solution to your problem either manually or through macro. I am searching for the same. If I find it I'll let you know. May be someone else will do it for you
 
Thank you Iam just want to be clear.By this way I shared this explanation.I am glad to help :)
 
Hi,

First advice, check Eric's post about posting pictures, if you are on a mobile connection you don't want to do traffic downloading a bmp file with big size, so you will not get an answer so soon.

Second advice is to check the v5automation.chm file in CATIA installation folder, there is an example there how to copy-paste-keep-absolute-position of a product, you can use it to understand more things.


Regards
Fernando

 
Firts of all thank you a lot dear ferdo.I cared your advices appreciately. Altough I have subscirption his blog, the blog still ask me password and I did not receive any password from.Just an email is sent and it said "EMAIL Subscription Confirmed" but I dont still access.

Secondly I tried to entegrate copy-paste code unfortunately I am unsuccesful about this.I add text file.This file returns "set component is not supported in Visual basic" compile error.How can I figure out?

Regards
 
 http://files.engineering.com/getfile.aspx?folder=5a8b0bc2-c3a1-4454-943a-52d1e354accd&file=position_calculation.txt
Actually it is confusing.briefly ı try to explain again sorry about amateur student mavement:( I add new one.I understood calculation matrix and inverse but how can I have myInputPart's X,Y,Z values?I mean my target is which I want to have position values I want to access,so I did not entegrate and call in CATMain.If I didnot tell I can try can and give more detail.
 
 http://files.engineering.com/getfile.aspx?folder=4e3dbb40-a0ba-4505-ad93-7cc23a19f449&file=position_calculation_(1).txt

This is what you are looking for:

Code:
...

Dim oAxisComponentsArray(11)

[i]prod[/i][highlight #FCE94F].Position.GetComponents[/highlight] oAxisComponentsArray

...

Check the online doc to understand the oAxisComponentsArray(11) values...

Eric N.
indocti discant et ament meminisse periti
 
Thank you itsmyjob.I checked v5automation.chm before and until the now I understood that RotX,RotY,RotZ values(it means you know for example:45degrees,0 degrees,90 degrees etc.)I cannot reach by this method.Can you give me any idea for this problem?
 
Well, you will have to do some math as this is what CATIA gives you.

Eric N.
indocti discant et ament meminisse periti
 
It is OK itsmyjobs I will struggle about this.I am glad your support.I hope overcome that.
REGARDS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top