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!

GetCoordinates of a Point in Drawing View

Status
Not open for further replies.

PrasannaNX

Automotive
Aug 5, 2014
31
IN
Hi,

I am using Catia VBA Editor for finding the coordinates of a point in drawing view.
For some reason "GetCoordinates" method of Point2d object doesn't return anything in VBA.
The same is working fine with C#.

Exact issue as mentioned in this thread:
Alternatively:
Manually i tried using "Measure Item" in Catia and selected the point in drawing view which gives me the Coordinates of the point relative to the view.
How do i automate Measure Item" in Drawing Document.

Measurable.GetMeasurable(CATIAReference iMeasuredItem) needs CATIAReference as parameter.
How can i create CATIAReference for an object in drawing document?

Like in PartDoc "Partdocument.Part.CreateReferenceFromObject"
How do i get in DrawingDoc "Drawingdocument.?"

Thanks,
Prasanna M
 
Replies continue below

Recommended for you

All methods work the same whatever language you use.

I believe you get "Function or interface resteicted" error which may be swallowed by uneducated use of "On Error" statements.

Post your code.
 
You are correct. I overlooked the code.
Thanks.

Code:
Sub Main()
Dim catDrwDoc As DrawingDocument
Set catDrwDoc = CATIA.ActiveDocument

Dim catDrwSel As Selection
Dim catDrwSelLb As Object

Set catDrwSel = catDrwDoc.Selection
Set catDrwSelLb = catDrwSel

Dim objFilter(0) As Variant
objFilter(0) = "Point2D"

Dim strStatus As String
strStatus = catDrwSelLb.SelectElement2(objFilter, "Select point in drawing view", False)

Dim catDrwViewPoint As Point2D
Dim catDrwViewPointLB As Object
If strStatus = "Normal" Then
    Set catDrwViewPoint = catDrwSel.Item2(1).Value
    Set catDrwViewPointLB = catDrwViewPoint
End If

Dim arrCoords(2)
catDrwViewPointLB.GetCoordinates arrCoords

MsgBox "X Coord : " + CStr(arrCoords(0)) + Chr(10) + "Y Coord : " + CStr(arrCoords(1)) + Chr(10)

End Sub
 
Thank for posting the code.

Note to everyone how "interface marked as restricted" error was worked around by typing actual Selection object "as Object"

Dim catDrwSelLb As Object
 
@Little Cthulhu,
Follow-up question of my original post.
Will there be a need of using CATIAReference object in drawing?
If yes, how do i actually create a CATIAReference in drawing document?

Just to know in case i come across a case where i need to use CATIAReference in drawing in future.

Thanks,
Prasanna M
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top