Lenth Calculations

Lenth Calculations

Anonymous
Not applicable
442 Views
8 Replies
Message 1 of 9

Lenth Calculations

Anonymous
Not applicable
Hi every body,
I am using VBA for automation of drawing. In this I am drawing a line.To draw a line using VBA, you need to enter Strat Point & End Point. For general cases, I have length of line and its angle of full circle bearing. For example--I want to darw-
@100'<156d24'45"

But in VBA, i need to enter start point and end point. I tried it using Trigometric formula, to get the end point as i am provided with length and its angle. But could not generalize formula for all angles.
Does any body have generalized method to find end point from start point for all angles?
or
It can be directly draw a line with length and angle in VBA?

Second problem--
How can set preferences like direction of angles(By default for my template is east, but i want to make it North, want to measure clockwise) using VBA.
0 Likes
443 Views
8 Replies
Replies (8)
Message 2 of 9

Anonymous
Not applicable
You just have to split your formula up depending on which direction the line is running. (NE,SE,NW,SW) -- Ben - cheesy creamy cheesy My mother called me that once.... once! ------------------------------------------------------------------------ Ben's Profile: http://www.vbdesign.net/expresso/member.php?action=getinfo&userid=201 View this thread: http://www.vbdesign.net/expresso/showthread.php?threadid=59836
0 Likes
Message 3 of 9

Anonymous
Not applicable
See the help for AngleToReal and DistanceToReal methods. I guess you'd have to split your strings at the "@" and "<". HTH, James .
0 Likes
Message 4 of 9

Anonymous
Not applicable
In addition, calc the endpoint using "PolarPoint" method.... Jeff "James Belshan" wrote in message news:403f6d61$1_3@newsprd01... > See the help for AngleToReal and DistanceToReal methods. I guess you'd have > to split your strings at the "@" and "<". > HTH, > James > . > >
0 Likes
Message 5 of 9

Anonymous
Not applicable
Hi Kumar, Calculate the second end point with "Thisdrawing.Utility.PolarPoint". The help files describe it in detail. The posts about quadrants and string splitting are totally irrelevant to your question. -- Laurie Comerford CADApps www.cadapps.com.au "Kumar" wrote in message news:3364381.1077896860449.JavaMail.jive@jiveforum2.autodesk.com... > Hi every body, > I am using VBA for automation of drawing. In this I am drawing a line.To draw a line using VBA, you need to enter Strat Point & End Point. For general cases, I have length of line and its angle of full circle bearing. For example--I want to darw- > @100'<156d24'45" > > But in VBA, i need to enter start point and end point. I tried it using Trigometric formula, to get the end point as i am provided with length and its angle. But could not generalize formula for all angles. > Does any body have generalized method to find end point from start point for all angles? > or > It can be directly draw a line with length and angle in VBA? > > Second problem-- > How can set preferences like direction of angles(By default for my template is east, but i want to make it North, want to measure clockwise) using VBA.
0 Likes
Message 6 of 9

Anonymous
Not applicable
Laurie, I read Kumar's post to mean that the input to his program would be similar to @100'<156d24'45" and his program would need to turn this into a length in inches and an angle in radians. Kumar, VBA coordinates are all based on the World Coord System, which as far as I know is always (0 deg to the right, 90 deg is upward when looking at the screen). Easiest way to work with a different compass is probably to just make a conversion function. HTH, James
0 Likes
Message 7 of 9

Anonymous
Not applicable
I'll have to remember that one, hadn't used PolarPoint before. Cheers! -- Ben - cheesy creamy cheesy My mother called me that once.... once! ------------------------------------------------------------------------ Ben's Profile: http://www.vbdesign.net/expresso/member.php?action=getinfo&userid=201 View this thread: http://www.vbdesign.net/expresso/showthread.php?threadid=59836
0 Likes
Message 8 of 9

Anonymous
Not applicable
I made an example just 10 minutes ago, I don't know whether this one can solve you problem. see attached file.
0 Likes
Message 9 of 9

Anonymous
Not applicable
Uhmm, just a quick look and seems to me that your Sub is wrong x2 and y2 are deltaX and deltaY not the actual coordinates of point 2 It should be: PX2 = x1 + x2 PY2 = y1 + y2 >Private Sub CommandButton3_Click() > > > Dim startPoint(0 To 2) As Double > Dim endPoint(0 To 2) As Double > Dim x1, y1, length, angle, x2, y2 As Single > > x1 = CSng(Trim(TBX)) > y1 = CSng(Trim(TBY)) > length = CSng(Trim(TBLength)) > angle = CSng(Trim(TBAngle)) > x2 = length * Cos(angle * 3.1415 / 180) > y2 = length * Sin(angle * 3.1415 / 180) > ' Define the start and end points for the line > startPoint(0) = x1: startPoint(1) = y1: startPoint(2) = 0 > endPoint(0) = x2: endPoint(1) = y2: endPoint(2) = 0 >Dim lineobj As AcadLine >' Create the line in model space > Set lineobj = mospace.AddLine(startPoint, endPoint) > Set lineobj = paSpace.AddLine(startPoint, endPoint) > ZoomAll > > End Sub -- Saludos, Ing. Jorge Jimenez, SICAD S.A., Costa Rica (sorry, phony e-mail, SPAM made me do it) "jjin" wrote in message news:10866382.1077930454236.JavaMail.jive@jiveforum1... > I made an example just 10 minutes ago, I don't know whether this one can solve you problem. see attached file.
0 Likes