cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

How to work out length and angle between 2 picked points?

Level 9

How to work out length and angle between 2 picked points?

I'm trying to create a little macro that gets the user to click 2 points on the drawing and then draws a bezier curve between the two points. Of course I need to work out all the positions required for the bezier curve: Start point - known Position for first handle - this needs to be worked out relative to the position and angle of the end point. Position for second handle - again needs working out. End Point - known. I'm used to Co Create's ME10 macro language which has functions to work out things such as the length and angle between 2 points so that trig functions can be applied to work out new points relative to known ones. How is this done in Isodraw? Also, how do you prompt the user to pick the start and end points - there is no command line in Isodraw so the only way I've found to do it is to use the message function that required the user to close the message before picking the point, so no use really.
13 REPLIES

Not as simple as you think

Though IsoDraw does allow for a lot of functionality through the macro language, it can be a bit length getting to where you need. To get the points from the user
17cfc43dbe
You would likely do this twice, once directly after the first, to allow the selection of the first and then second points. Note that the variables would need to change to say F3 and F4 as to not overwrite your initial coordinates. In regards to prompting, you have only one choice, and that is the message command. I might recommend leaving out the prompt however, as the user likely will assume that selecting the macro Draw_a_bezier (or similar) will prompt for the two points. To determine the math for angles, etcetera, that is not quite as simple as you might hope. I'd recommend the Function section of the macro help from under the menu to get some trig commands.

RE: Not as simple as you think

Thanks Trevor I've got as far as getting the first and second points OK. The problem I have is working out the relationship between them (length betweeen the points and the angle between them) so that I can apply the trig functions properly.

Not very good at trig

I was never very good at trig unfortunately. I'd think your starting point would be to X and Y differences. Maybe something along the lines of comparing the points. Check if F1 is greater than F3, if so, F1-F3. Otherwise, F3-F1. Do the same with F2 and F4. That will give you the rise and run of your triangle. You should be able to determine your slope from that. As I said, it's not as simple as what you think. If you are still stuck, give a little more detail, specifically with determining handle locations. I can't promise today, but I can see what I can do with it.

Trig help

My wife, the math major, was kind enough to put together some basic trig functions. Attached is a cheat sheet that should assist you. For reference, the points you gather (F1, F2, F3, and F4) allow you to determine the X and Y coordinates.

RE: Trig help

Thanks Trevor. I think with this information and the invaluable cheat sheet I should be able to get this done. I used to use trig a lot a few years ago but never knew which one to use and when. My main problem is the transition from ME10 macro language to this one - the syntax is so different and there are far fewer commands in Isodraw to help with drawing related macros. Thanks to your wife for the cheat sheet, it will be a very useful reference. If I get this macro done, I'll probably post it here so people can have a giggle at my coding.

Bezier between two points

Hello gentlemen, I believe this is a further good example for the "user helps user" system. Great work! Tim, can you detail a bit what the use case behind this function is? E.g. do you want to add your own measure function? [Edit: Or what do you need the coordinates and angles for?] Thank you, Christian

RE: Bezier between two points

I was a full time programmer for ME10 - CoCreate's 2d CAD system for over 10 years and did macros to effectively add new features (to automate standard drawing tasks), so I thought it would be good to do the same with Isodraw. I'm finding it difficult as the structure of the language is so different and the drawing commands don't seem very flexible. I may have been a little sheltered as the ME10 macro language is superb, intuitive and has lots of drawing functions. Anyway, there are some things that Isodraw does not have functions for that we use quite a lot - for example drawing ribbed pipes (takes ages manually). To start off though, I just wanted to do a very simple macro to draw the elliptical shape representing the end of a cut off bar or pipe (don't know if it has a name). The attached .jpg file shows an example of what I'm trying to do. The idea is to just pick 2 points (the ends of the pipe) and the macro works out the angle of the points and draws the ellipses to suit. It doesn't look like you can draw segments of curves (or can you?) so I'm trying to use bezier curves instead, and need to work out the positions to place the handles so the curves look OK.

A place to start...

I believe you are correct in the use of bezier cures. I'd recommend starting with the "Create bezier" command and then adding by using the "Append bezier segment" command. An example is below. I'll see if I can figure it out, but I have to admit that this is a fairly complex endeavor so it might be a bit before I have enough time to work on this. create bezier curve 100 100 150 100 150 200 200 200 append bezier segment 250 200 250 100 300 100 append bezier segment 350 100 350 200 400 200 append bezier segment 450 200 450 100 500 100 A note for Christian, This is a common issue. At this point, we've been manually creating this effect on our end, but a macro would be beneficial.

Cut pipe symbol with macro

Hi, thanks for the details, that really sounds interesting. I guess it will be possible but the alignment and length of the anchor points handles might be a bit challenging. Attached a screenshots of the handles as I would set them. You may also create different macros which consider to which direction the cut pipe is open afterwards. Much success, Christian