PDA

View Full Version : Point Angle


brm
10-05-2005, 01:38 AM
See The Enclosed Fig_1.
How Can Do To Define The P4 Point With A Macro.

Thom Ivancso
10-05-2005, 04:55 AM
Hello brm,

Your image did not get attached correctly it seems, could you attach a new one to the post?

I also moved your last two posts to the Customizataion thread, since they are not a Drafting usage question.


Cheers,
Thom :)

brm
10-05-2005, 05:22 AM
New Picture.

brm
10-05-2005, 05:24 AM
New Pictures.

Thom Ivancso
10-05-2005, 06:10 AM
brm,

How is your macro generating points P1 through P3?

Cheers,
Thom

brm
10-05-2005, 09:56 PM
It's the same to extend line applied to oblique line.

The point to find is P5.

DEFINE st_line

LOCAL P1
LOCAL E1
LOCAL P2
LOCAL P3
LOCAL ang_linea
LOCAL D1_2
LOCAL D1_3
LOCAL P4
LOCAL P5

LOOP

LOOP
READ PNT 'Indicate line, near end to extend.' P1
INQ_ELEM P1
LET E1 (INQ 403)
EXIT_IF (E1=LINE)
END_LOOP

IF (E1=LINE)
LET P2 (INQ 101)
LET P3 (INQ 102)
LET ang_linea (ANG(P2-P3))
MEASURE_DISTANCE P1 P2
LET D1_2 (INQ 3)
MEASURE_DISTANCE P1 P3
LET D1_3 (INQ 3)
END_IF

IF (D1_2<D1_3)
LOOP
READ PNT 'Indicate next point.' RUBBER_LINE_ANG P2 (ang_linea) P4
EXIT_IF ((P4<>P1)AND(P4<>P2)AND(P4<>P3))
END_LOOP
ELSE_IF (D1_2>D1_3)
LOOP
READ PNT 'Indicate next point.' RUBBER_LINE_ANG P3 (ang_linea) P4
EXIT_IF ((P4<>P1)AND(P4<>P3)AND(P4<>P2))
END_LOOP
END_IF

used for horizontal line

IF ((D1_2>D1_3)AND(((Y_OF P2)=(Y_OF P3))AND((X_OF P4)>(X_OF P3))))
LET P5 (PNT_XY (X_OF P4) (Y_OF P3))
MODIFY SCALE CENTER P2 P3 P5 P1 END
ELSE_IF ((D1_2>D1_3)AND(((Y_OF P2)=(Y_OF P3))AND((X_OF P4)<(X_OF P3))))
LET P5 (PNT_XY (X_OF P4) (Y_OF P3))
MODIFY SCALE CENTER P2 P3 P5 P1 END
END_IF

END_LOOP

END_DEFINE

John Scheffel
10-06-2005, 10:52 AM
I'm don't understand how your macro points (P1, P2...) relate to the points in your bitmap image.

In the image, both ends of the line are labled as P1. There is a point P4 on the line and a point P3 90 degrees of the line at some unspecified distance.

In your macro, the user is prompted to pick P1 which is a point on the line. The endpoints of the selected line are set to P2 and P3. The user is then prompted to pick P4 which is different than P1, P2 or P3 but on the line.

Can you provide a description of what you want this macro to do? It still isn't clear to me.

brm
10-06-2005, 09:54 PM
Sorry but this macro should used to extend a line.
The picture is an example.
First select the line P1 then define the point to extend P4.
If the line is not horizontal or vertical i have difficult to applied this macro
with scale command.
The point P4 is used to define the point P5 that is the projection of P4 on the line.
Is possible calculate it?

John Scheffel
10-07-2005, 02:08 PM
I'm still not sure I completely understand what you are trying to do. When you say "extend" a line, do you mean create a line? From your original bitmap it appears you want to create a new line perpendicular to the line selected by P1 and intersecting at selected point P4. If this is the case, have you considered using the LINE command? Something like the following might work.

LINE PERPENDICULAR P1 P4

Does this do what you want?

brm
10-09-2005, 10:06 PM
This command should be a strech line command without deleting the original line but extended by scale command.
The perpendicular line P3-P4 in the picture is an imaginary line.
By the point P3 is possible calculate the point P4 and strech the line up to P4?

John Scheffel
10-10-2005, 04:25 PM
Try this. It doesn't do exactly what you want. It deletes the original line and creates a new line instead of extending the existing line. But I think the end result is what you want.

DEFINE st_line
LOCAL P1
LOCAL E1
LOCAL P2
LOCAL P3
LOCAL ang_linea
LOCAL D1_2
LOCAL D1_3
LOCAL P4
LOCAL P5
LOOP
LOOP
READ PNT 'Indicate line, near end to extend.' P1
INQ_ELEM P1
LET E1 (INQ 403)
EXIT_IF (E1=LINE)
END_LOOP
IF (E1=LINE)
LET P2 (INQ 101)
LET P3 (INQ 102)
LET ang_linea (ANG(P2-P3))
MEASURE_DISTANCE P1 P2
LET D1_2 (INQ 3)
MEASURE_DISTANCE P1 P3
LET D1_3 (INQ 3)
END_IF
IF (D1_2<D1_3)
LOOP
READ PNT 'Indicate next point.' RUBBER_LINE_ANG P2 (ang_linea) P4
EXIT_IF ((P4<>P1)AND(P4<>P2)AND(P4<>P3))
END_LOOP
DELETE P1
LINE PT_ANG_DIST P3 ang_linea P4 END
ELSE_IF (D1_2>D1_3)
LOOP
READ PNT 'Indicate next point.' RUBBER_LINE_ANG P3 (ang_linea) P4
EXIT_IF ((P4<>P1)AND(P4<>P3)AND(P4<>P2))
END_LOOP
DELETE P1
LINE PT_ANG_DIST P2 ang_linea P4 END
END_IF
END_LOOP
END_DEFINE

brm
10-10-2005, 10:40 PM
THANK YOU, it is A VALID SOLUTION, ALSO If SHOULD BETTER don't CANCEL THE LINE.
HOW COME THIS MACRO doesn't ALWAYS WORK.
IT WORK TWO Or THREE TIMES IN THE SAME LINE THEN doesn't MODIFY.
FOR HORIZONTAL LINES.

DEFINE st_line

LOCAL P1
LOCAL E1
LOCAL P2
LOCAL P3
LOCAL ang_linea
LOCAL D1_2
LOCAL D1_3
LOCAL P4
LOCAL P5

LOOP

LOOP
READ PNT 'Indicate line, near end to extend.' P1
INQ_ELEM P1
LET E1 (INQ 403)
EXIT_IF (E1=LINE)
END_LOOP

IF (E1=LINE)
LET P2 (INQ 101)
LET P3 (INQ 102)
LET ang_linea (ANG(P2-P3))
MEASURE_DISTANCE P1 P2
LET D1_2 (INQ 3)
MEASURE_DISTANCE P1 P3
LET D1_3 (INQ 3)
END_IF

IF (D1_2<D1_3)
LOOP
READ PNT 'Indicate next point.' RUBBER_LINE_ANG P2 (ang_linea) P4
EXIT_IF ((P4<>P1)AND(P4<>P2)AND(P4<>P3))
END_LOOP
ELSE_IF (D1_2>D1_3)
LOOP
READ PNT 'Indicate next point.' RUBBER_LINE_ANG P3 (ang_linea) P4
EXIT_IF ((P4<>P1)AND(P4<>P3)AND(P4<>P2))
END_LOOP
END_IF

IF ((D1_2>D1_3)AND(((Y_OF P2)=(Y_OF P3))AND((X_OF P4)>(X_OF P3))))
LET P5 (PNT_XY (X_OF P4) (Y_OF P3))
MODIFY SCALE CENTER P2 P3 P5 P1 END
ELSE_IF ((D1_2>D1_3)AND(((Y_OF P2)=(Y_OF P3))AND((X_OF P4)<(X_OF P3))))
LET P5 (PNT_XY (X_OF P4) (Y_OF P3))
MODIFY SCALE CENTER P2 P3 P5 P1 END
END_IF

DELETE SELECT POINTS ALL CONFIRM END
WHITE

END_LOOP

END_DEFINE

John Scheffel
10-11-2005, 09:47 AM
I tried your macro, and you are correct that after a few times it stops working. As far as I can tell it never works if I pick the left side of a horizontal line. If I pick the right side it works for a few tries then stops working.

I'm not sure exactly why, but I ran a TRACE and the logic around the MODIFY SCALE commands was returning zero for both the IF and ELSE_IF tests. So neither of the MODIFY commands being run so the line is not modified.

I'm not sure I understand what this logic is trying to determine and don't have more time to spend on it. If you really want to debug it, try using the TRACE command to see what your macro is doing. Just enter something like the following on the Drafting command line:

TRACE DEL_OLD 'C:\temp_trace.txt'

Then run your macro. When it starts failing enter TRACE OFF on the command line. Then open the above file in a text editor and try to determine why the logic is returning zero for both tests.

Thom Ivancso
10-11-2005, 02:13 PM
Hello brm,

I guess one question I would like to ask is what is the use model for this macro, what is the user trying to accomplish with it?

It might give us a better understanding on how it is suppose to work.

Cheers,
Thom

brm
10-11-2005, 10:28 PM
THIS MACRO should ALLOW to MODIFY FREELY The LENGTH Of A LINE.
THE MACRO STRECH_LINE DOWNLOADED, CANCEL THE EXISTING LINE it Is Not CORRECT , BECAUSE If there ARE DIMENSIONS CONNECTED TO THIS LINE will COME DELETED.

John Scheffel
10-14-2005, 04:10 PM
OK, I think I finally understand exactly what you want the macro to do. Try this one.

DEFINE Stretch_line

LOCAL Pick_pnt1
LOCAL Pick_pnt2
LOCAL Pick_type
LOCAL Epnt_1
LOCAL Epnt_2
LOCAL Line_angle
LOCAL Line_length
LOCAL Seg_1
LOCAL Seg_2
LOCAL Keep_pnt
LOCAL Pick_dist
LOCAL Theta
LOCAL Trim_dist
LOCAL Trim_pnt

LOOP
LOOP
READ PNT 'Indicate line, near end to extend.' Pick_pnt1
INQ_ELEM Pick_pnt1
LET Pick_type (INQ 403)
EXIT_IF (Pick_type=LINE)
END_LOOP

LET Epnt_1 (INQ 101)
LET Epnt_2 (INQ 102)
MEASURE_DISTANCE Epnt_1 Epnt_2
LET Line_length (INQ 3)
MEASURE_DISTANCE Pick_pnt1 Epnt_1
LET Seg_1 (INQ 3)
MEASURE_DISTANCE Pick_pnt1 Epnt_2
LET Seg_2 (INQ 3)

IF (Seg_1 > Seg_2)
LET Keep_pnt Epnt_1
LET Line_angle (ANG(Epnt_2-Epnt_1))
ELSE
LET Keep_pnt Epnt_2
LET Line_angle (ANG(Epnt_1-Epnt_2))
END_IF

LOOP
READ PNT 'Indicate next point.' RUBBER_LINE_ANG Keep_pnt Line_angle Pick_pnt2
EXIT_IF (Pick_pnt2<>Keep_pnt)
END_LOOP

MEASURE_DISTANCE Keep_pnt Pick_pnt2
LET Pick_dist (INQ 3)
LET Pick_angle (ANG(Pick_pnt2-Keep_pnt))
LET Theta (Pick_angle - Line_angle)
LET Trim_dist (Pick_dist*(COS Theta))
LET Trim_pnt (Keep_pnt + (PNT_XY (Trim_dist*(COS Line_angle)) (Trim_dist*(SIN Line_angle))))

MODIFY Pick_pnt1 SCALE CENTER Keep_pnt (Trim_dist/Line_length)
END_LOOP

END_DEFINE

brm
10-21-2005, 12:08 AM
Thank You It's Work Correctly. :)