OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 02-09-2008, 22:23
m31uk3
Guest
 
Posts: n/a
Default Angle of adjacent segments

Starting and Ending Control Point Angels are available for the nodes of a curve but they are rather confusing.

I would like to write a script which would highlight the angle of adjacent segments which are greater than X degrees.

For example the image below one angle of the square has been changed to have a very drastic angle.



I have tried to use Starting and Ending Control Point Angels of the segments but didn't manage to understand anything.

Code:
Sub Tes323rt2()

 Dim n As Node
 
 Dim x As Double, y As Double
 
 Dim s As Shape

 For Each n In ActiveShape.Curve.Nodes
    If n.Type = cdrCuspNode Then
        n.GetPosition x, y
        Set s = ActiveLayer.CreateEllipse2(x, y, 0.01)
        s.Outline.Color.RGBAssign 255, 255, 0
        'MsgBox n.PrevSegment.StartingControlPointAngle & " - " & n.Segment.EndingControlPointAngle & " - " & n.Segment.StartingControlPointAngle & " - " & n.NextSegment.EndingControlPointAngle
        MsgBox n.Segment.StartingControlPointAngle & " - " & n.Segment.EndingControlPointAngle
    End If

 Next n

End Sub


Private Sub MarkPoint33(seg As Segment, t As Double)

 Dim x As Double, y As Double

 Dim s As Shape

 seg.GetPointPositionAt x, y, t

 Set s = ActiveLayer.CreateEllipse2(x, y, 0.03)

 s.Outline.Color.RGBAssign 255, 255, 0

End Sub
I would assume this would relate somehow to fillet however regardless of the length of the segment I still want to highlight any angles which are drastic like the one pictured above.

Thanks in advance for any help!
Reply With Quote
  #2  
Old 06-09-2008, 01:57
m31uk3
Guest
 
Posts: n/a
Default

It it just a hard request or that nobody wants to help me
Reply With Quote
  #3  
Old 08-09-2008, 21:23
m31uk3
Guest
 
Posts: n/a
Default

I think that narrowing it down to only cusp type nodes should help but I am still stumped with the adjacent angles.

Is everyone stumped aswell?
Reply With Quote
  #4  
Old 09-09-2008, 02:02
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,769
Blog Entries: 9
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Maybe...

This is as close as I have time for....it does pretty well but it not perfect. Hopefully it will give you a hint or two...
Code:
Sub WhatsMyAngle()
    Dim s As Shape
    Dim nr As New NodeRange
    Dim segBefore As Segment
    Dim segAfter As Segment
    Dim da As Double
    Dim n As Node

    Set s = ActiveShape

    For Each n In s.Curve.Nodes
        Set segBefore = n.PrevSegment
        Set segAfter = n.NextSegment

        If Not segBefore Is Nothing And Not segAfter Is Nothing Then
            da = segBefore.EndingControlPointAngle - segAfter.StartingControlPointAngle
            ActiveLayer.CreateArtisticText n.PositionX, n.PositionY, Round(da, 0) & " degrees", , , "Ariel", 10, , , , cdrCenterAlignment
        End If
    Next n
End Sub
Best of luck,

-Shelby
Reply With Quote
  #5  
Old 09-09-2008, 12:09
m31uk3
Guest
 
Posts: n/a
Default

You Rock!

This is exactly what I needed to get me started.

I will test it out and post back.

Thank You!
Reply With Quote
  #6  
Old 08-08-2012, 05:20
cabir cabir is offline
Junior Member
 
Join Date: Jul 2012
Posts: 4
Default

hi Shelbym

in this example can you please help me
in a shape like lets say capital A or a square. I am trying to find the angles but the problem is to find if the angle if it is looking inside the object or outside.
It is important when I try to extrude the object with a strip.
When I try something and think that ? find the result and change the direction of the object that I see I am not successful
Reply With Quote
  #7  
Old 12-09-2012, 09:45
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,769
Blog Entries: 9
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Angle

The following modified code will show a positive angle inside the shape:
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
    
    For Each n In sShape.Curve.Nodes
        Set segBefore = n.PrevSegment
        Set segAfter = n.NextSegment
        
        If Not segBefore Is Nothing And Not segAfter Is Nothing Then
            da = segBefore.EndingControlPointAngle - segAfter.StartingControlPointAngle
            If da < 0 Then da = 360 + da
            ActiveLayer.CreateArtisticText n.PositionX, n.PositionY, Round(da, 0) & " degrees", , , "Ariel", 8, , , , cdrCenterAlignment
        End If
    Next n
End Sub
Best of luck,

-Shelby
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Subpaths, Segments, and Nodes m31uk3 CorelDRAW/Corel DESIGNER VBA 7 20-06-2008 12:28
Resizing Line Segments norbert_ds CorelDRAW/Corel DESIGNER VBA 8 24-04-2007 02:08
Rotation Angle norbert_ds CorelDRAW/Corel DESIGNER VBA 1 20-04-2007 03:39
Creating lines using angle, dimension and position Bobbejaan Code Critique 3 05-04-2007 08:22
[DrawX3 bug] interface display of fractional angle/size wOxxOm General 0 18-02-2006 15:00


All times are GMT -5. The time now is 02:59.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com