Author Topic: Strange rotation  (Read 2518 times)

0 Members and 1 Guest are viewing this topic.

S.Langhammer

  • Guest
Strange rotation
« on: December 03, 2013, 09:06:30 AM »
Hey everyone!

There's a strange rotation in one of the drawings, that have been converted with my lisp script.

You can see it in the attached files "before" and "after". After shows a part of our programm.

In the example.txt I attached is the block like I found it in the DXF file, as well as the insert.

As far as I can tell, they should match. My script converts LWPolylines to lines to make them easier/faster readable. Is there anything I missed? Or is the error in the other programm?

Thanks in advance!

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Strange rotation
« Reply #1 on: December 03, 2013, 03:12:14 PM »
On line 117 the dxf angle for the insert in degrees is:
100.993173281319

On line 133 your output angle in radians (?) is:
0.1919
Which is ca. 10.8862 degrees

These angles differ by ca. 90 degrees as the images clearly show.
It seems that you have missed something.

S.Langhammer

  • Guest
Re: Strange rotation
« Reply #2 on: December 04, 2013, 02:42:24 AM »
The strange thing is though, when I click the Block Reference in the drawing it says the Rotation is 10.9932 degrees.

I should have put that to the screenshot. Yes the output is in radians.

When I look at this, the difference between 10.9932 degrees (like bricscad tells me) and 10.8862 degrees (like you calculated) is already a lot smaller than the difference to the dxf file.

When I enter 100.9932 to the rotation in bricscad, the block reference looks wrong again.

S.Langhammer

  • Guest
Re: Strange rotation
« Reply #3 on: December 04, 2013, 04:12:57 AM »
I figured this might help to understand:

Code - Auto/Visual Lisp: [Select]
  1. (fileWrite(strcat "INSERT,"(cdr(assoc 8 ent))"," entName ","(rtos(-(car entPt)(car blkPt))2 4)","(rtos(-(cadr entPt)(cadr blkPt))2 4)","(rtos(-(caddr entPt)(caddr blkPt))2 4)","(rtos(cdr(assoc 41 ent))2 4)","(rtos(cdr(assoc 42 ent))2 4)","(rtos(cdr(assoc 43 ent)) 2 4)","(if(setq entRot(cdr(assoc 50 ent)))(vl-string-right-trim "r"(angtos entRot 3 4))"0")","(rtos(car entNorm)2 4)","(rtos(cadr entNorm)2 4)","(rtos(caddr entNorm)2 4)))
  2.  

ent = entity
entPt = insertion point
blkPt = base point of the block
entName = name of the block
entRot = rotation
entNorm = extrusion vector

I don't really see how I got an error into this. The rotation should be just fine the way I understand it.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Strange rotation
« Reply #4 on: December 04, 2013, 06:07:39 AM »
The angles the CAD program reports to the user depend on the settings of ANGBASE and ANGDIR. The standard value for ANGBASE is 0.0. I think you are using a different value (90.0).

Internally entity angles are stored in a default manner:
The zero angle is the positive X axis (in the OCS).
The direction of the angle is CCW (in the OCS).

The values of both variables influence the results of (angtos). You should just use (rtos) instead.

S.Langhammer

  • Guest
Re: Strange rotation
« Reply #5 on: December 04, 2013, 06:44:44 AM »
You were right about the ANGBASE and ANGDIR. Since it would cause more work on the delphi side of the interface to change it from radians to angle, I'm setting the variables at the begin of the script and set them back at the end.

Thanks a lot!