#1




Finding Angle
I have several lines in my drawing, how can i just click on the line and find its angle with refrence to universal X axis. The precision should be up to 3 digits (eg. 23.215º) is it possible. Using the dimension tool is a bit problem since several of my lines are close to each and so the linee snaps to wrong node.

#2




Angle
Select a single node and run this code, it will give you the angle. You might have to play with it a bit to get it to display the angle you want, for instance now it might give you 90 and such. But you should be able to get started with this.
Code:
Sub WhatIsMyAngle() Dim n As Node Dim sShape As Shape Dim segBefore As Segment Dim segAfter As Segment Dim da As Double Set sShape = ActiveShape If sShape Is Nothing Then MsgBox "Nothing selected", vbCritical Exit Sub End If If sShape.Type <> cdrCurveShape Then MsgBox "A curve object must be selected", vbCritical Exit Sub End If If sShape.Curve.Selection.Count <> 1 Then MsgBox "Only one node must be selected", vbCritical Exit Sub End If Set n = sShape.Curve.Selection(1) Set segBefore = n.PrevSegment Set segAfter = n.NextSegment If Not segBefore Is Nothing And Not segAfter Is Nothing Then da = segBefore.EndingControlPointAngle  segAfter.StartingControlPointAngle MsgBox Round(da, 3) & " degrees" End If End Sub Shelby 
#3




Almost there
Thanks a lot
Actualy this is not what I was looking for but this too will be very very useful. And it does get me near to what I want. All the lines in my drawing have only 2 nodes. So what I did is added an extra node and it works. I changed da = segBefore.EndingControlPointAngle  segAfter.StartingControlPointAngle to da = segBefore.EndingControlPointAngle  0 so now it gives me angle with relation to x axis of the page. The only problem is when the angle is above 90 it displays it as negetive (like 92 is 88) so I need to add 180 to 'da' if the value of 'da' is negetive but I dont know how to do it. I am ataching that file for ref Thanks a lot 
#4




getting angle of line segment
you can use atn() function
atn(y/x)*180/3.142 where 'y' is height, 'x' is width of line as shown in the property bar 180/3.14 converts radian to degree 
#5




getting angle
Private Function atan2(y As Double, x As Double) As Double
Dim y1 As Double Dim a As Double If x = 0 Then a = 1.5707963267949 * Sgn(y) Else a = Atn(y / x) y1 = IIf(y <> 0, y, 1) If x < 0 Then a = a + 3.14159265358979 * Sgn(y1) End If atan2 = a End Function put these codes in form then you can get y & x via command button or from globalselection change event y is height, x is width of the line as shown in the property bar when you select the line 
#6




crating form
Thanks Aakkaarr
mathematicall I like your idea, thanks a lot, but sice I am not a VB guy I dont know how to put the codes in a form, I will be glad if you can help me there Also is there a link where I can learn it. 
#7




It Works
He Shelbym it works nice it has stoped showning negetive angle. Thanks a lot
I just made small change Sub WhatIsMyAngle() Dim n As Node Dim sShape As Shape Dim segBefore As Segment Dim segAfter As Segment Dim da As Double Set sShape = ActiveShape If sShape Is Nothing Then MsgBox "Nothing selected", vbCritical Exit Sub End If Once again Thanks a lot If sShape.Type <> cdrCurveShape Then MsgBox "A curve object must be selected", vbCritical Exit Sub End If If sShape.Curve.Selection.Count <> 1 Then MsgBox "Only one node must be selected", vbCritical Exit Sub End If Set n = sShape.Curve.Selection(1) Set segBefore = n.PrevSegment Set segAfter = n.NextSegment If Not segBefore Is Nothing And Not segAfter Is Nothing Then da = segBefore.EndingControlPointAngle  0 da = 180 + segBefore.EndingControlPointAngle  0 MsgBox Round(da, 3) & " degrees" End If End Sub 
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)  
Thread Tools  Search this Thread 
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Angle of adjacent segments  m31uk3  CorelDRAW/Corel DESIGNER VBA  6  12092012 08:45 
Finding a text into a layer  mateushenrico  CorelDRAW/Corel DESIGNER VBA  3  10092008 10:28 
Rotation Angle  norbert_ds  CorelDRAW/Corel DESIGNER VBA  1  20042007 02:39 
Creating lines using angle, dimension and position  Bobbejaan  Code Critique  3  05042007 07:22 
[DrawX3 bug] interface display of fractional angle/size  wOxxOm  General  0  18022006 14:00 