Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

CATScript - Line2D.GetOrigin returning wrong coordinates 1

Status
Not open for further replies.

jmarkus

Mechanical
Jul 11, 2001
377
I have a CATscript which is looping through lines on a drawing (the lines belong to some titleblock geometry) and extracting the start point (origin) of the lines.

For some reason, the results are not correct. For example, I have a line which I can manually check (double click on the line) and the end points of the line are correctly reported as (241.8, 26) & (421.8, 26), but the code returns the origin as (-685.8, 26). Since this line is on a drawing sheet, it is even stranger that it is returning a negative value for the X-coordinate.

The excerpt from my code is:
Code:
For Each TheGeom in GeomElems
[indent]If TypeName(TheGeom)="Line2D" then
[indent]TheGeom.GetOrigin(Org)
TheGeom.GetDirection(Dir)
MsgBox ("Origin: " & Org(0) & ", " & Org(1) & vbCrlf & "Direction: " & Dir(0) & ", " & Dir(1))
[/indent]
End If[/indent]
Next

Although my example shows the X-coordinate as negative (which belonged to a horizontal line), I also have vertical lines reporting negative Y-coordinates by the code (but, again, not when checked manually).

If anyone has some insight as to why this might be happening, or what I should check (does the drafting sheet use a different axis system?), then it would be much appreciated!

Thanks,
Jeff
 
Replies continue below

Recommended for you

where is your background origin located--can you see the blue x-y axis? or, if it is a view we are talking about--where is the view's origo?

regards,
LWolf
 
This is on the sheet background itself, not on any views.

Thanks,
Jeff
 
Strange ... It looks like X = 0 when the line is first time drawn and Y is taken from blue axis. This means your line was moved from original drawn position.

Try to use TheGeom.startpoint and getcoordinates from point as a workaround.







 
TudorM,

TheGeom is a Line2D object, and .startpoint is not a property of Line2D (it belongs to Curve2D).

Is there a way to cast the Line2D to Curve2D in order to try to extract .startpoint?

Thanks,
Jeff
 
Have you tried ?

set opoint = thegeom.startpoint
opoint.GetCoordinates (org)




 

TudorM,

I didn't realize I could get startpoint (& endpoint) from a Line2D using this method, since I didn't see it in the 'CAA V5 Visual Basic Reference' under the Line2D object. Thank you very much for pointing that out. I tried it and it works!

The point coordinates are now being reported correctly!

Thanks,
Jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor