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 24-06-2017, 14:57
aakkaarr aakkaarr is offline
Senior Member
 
Join Date: Jan 2009
Posts: 154
Default how to find X,Y position of the point where 2 objects touches

how to find X,Y position of the point where 2 objects touches
Attached Images
 
Reply With Quote
  #2  
Old 28-06-2017, 02:35
shark shark is offline
Senior Member
 
Join Date: Aug 2010
Location: Russia, Belgorod
Posts: 146
Default example from CorelDRAW VBA Help

Code:
Sub Test()
Dim sr As ShapeRange
Dim sp1 As SubPath, sp2 As SubPath
Dim cps As CrossPoints, cp As CrossPoint
Dim x As Double, y As Double, n As Long

 Set sr = ActiveSelectionRange
 If sr.Count <> 2 Then
    MsgBox "Please select two curves", vbCritical
    Exit Sub
 End If

 If sr(1).Type <> cdrCurveShape Or sr(2).Type <> cdrCurveShape Then
    MsgBox "One of the selected shapes is not a curve", vbCritical
    Exit Sub
 End If

 n = 0

 For Each sp1 In sr(1).Curve.Subpaths
  For Each sp2 In sr(2).Curve.Subpaths
   Set cps = sp1.GetIntersections(sp2)
   For Each cp In cps
    ActiveLayer.CreateEllipse2 cp.PositionX, cp.PositionY, 0.05
   Next cp
   n = n + cps.Count
  Next sp2
 Next sp1

 MsgBox n & " intersection point(s) found"
End Sub
Reply With Quote
  #3  
Old 09-07-2017, 12:24
aakkaarr aakkaarr is offline
Senior Member
 
Join Date: Jan 2009
Posts: 154
Default The example does not work with the objects touching not inersecting

The example does not work with the objects touching not intersecting
Reply With Quote
  #4  
Old 24-10-2017, 22:06
ager ager is offline
Member
 
Join Date: Jul 2010
Location: Russia
Posts: 44
Default sorry for the late answer

Code:
Sub touch()
Dim sr As ShapeRange, s As Shape, i As Long, k As Long, Xi As Double, Yi As Double
Set sr = ActiveSelectionRange
If sr.Count <> 2 Then Exit Sub
Set s = sr(1).Weld(sr(2))

With s.Curve
For i = 1 To .Nodes.Count
    For k = i + 1 To .Nodes.Count
        If .Nodes(i).GetDistanceFrom(.Nodes(k)) = 0 Then
            Xi = .Nodes(i).PositionX: Yi = .Nodes(i).PositionY
            ActiveLayer.CreateEllipse2 Xi, Yi, 0.02
        End If
    Next k
Next i
End With

End Sub
Reply With Quote
  #5  
Old 08-01-2018, 03:20
aakkaarr aakkaarr is offline
Senior Member
 
Join Date: Jan 2009
Posts: 154
Default Thank you very much

Thank you very much
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
I need to find the position of all nodes in an object MikeVerDuin CorelDRAW/Corel DESIGNER VBA 2 15-02-2011 21:05
Can i get more precise Position of Objects in CorelDRAW X4? iceage3 CorelDRAW/Corel DESIGNER VBA 3 01-05-2010 19:32
Find objects coordinates vrata CorelDRAW/Corel DESIGNER VBA 3 21-03-2010 15:29
How to find centers of objects vratis CorelDRAW/Corel DESIGNER VBA 1 06-01-2009 23:54
how to read point position (x/y) of any shape with VB-addin Andi CorelDRAW/Corel DESIGNER VBA 1 09-09-2004 08:32


All times are GMT -5. The time now is 21:35.


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