OberonPlace.com Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #11  
Old 16-04-2007, 00:22
wOxxOm's Avatar
wOxxOm wOxxOm is offline
Senior Member
 
Join Date: Mar 2005
Posts: 836
Default

oh, shape.Curve.Length is something I missed :-)

Shape.SetSize [width], [height] - accepts two parameters, both optional as indicated by square brackets, it sets width and height, not the length. Of course vertical and horizontal lines have one dimension and the length is equal to its linear horizontal/vertical dimension - that's why it works in case of .SetSize length-3 - because you specify only the first parameter which is width

Hint: use F2 key to invoke ObjectBrowser in VidualBasicEditor and see what are other methods - it also features search - for finding a method/property if you don't know the exact name/hierarchy. Also you can press Ctrl-I on the method to see quick parameters info, Shift-F2 to lookup method/property in ObjectBrowser without the need to find it manually (same as rightclick and choosing Definition)
Reply With Quote
  #12  
Old 17-04-2007, 07:32
norbert_ds
Guest
 
Posts: n/a
Default

So,

are you saying that shape.Curve.Length should have worked for horizontal as well as vertical lines? It doesn't.

Also I cannot imagine why a line should have a width parameter as well as a stroke weight?

Regds
Norbert
Reply With Quote
  #13  
Old 17-04-2007, 09:20
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

Any object has width and height. For horizontal lines, the height will be zero (pretty much) and for vertical lines the width will be almost zero. SizeWidth and SizeHeight methods return the width and height of the bounding box encompassing the object.

But Shape.Curve.Length gives a combined length of all the subpaths of the curve. For simple single-segment lines, that would be exactly the length of the line.
Reply With Quote
  #14  
Old 17-04-2007, 09:26
norbert_ds
Guest
 
Posts: n/a
Default

Thanks for that Alex,

But while I was trying to display via a msgBox Shape.Curve.length for both vertical and horizontal lines..... I got the required lenghts of the lines. But while I was trying to set Shape.Curve.length -3 to reduce the length by 3mm, the horizontal line worked while the vertical increased and that too not by any multiples of 3??

Thank you for replying

Norbert
Reply With Quote
  #15  
Old 17-04-2007, 09:37
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

Well, you were setting the width of the object to be Curve.Length - 3 which for the object of virtually no width would mean almost infinite scale up.

All you really need to do is see how much you need to scale your object down. For this, you need to calculate the scale factor of stretch by dividing the required length by the current length:

Code:
Sub ScaleLine()
    Dim dCurLength As Double, dTargetLength As Double
    Dim dScale As Double
    
    dCurLength = ActiveShape.Curve.Length
    dTargetLength = dCurLength - 3
    dScale = dTargetLength / dCurLength
    
    ActiveShape.Stretch dScale
End Sub
Reply With Quote
  #16  
Old 17-04-2007, 10:03
norbert_ds
Guest
 
Posts: n/a
Default

Quote:
Well, you were setting the width of the object to be Curve.Length - 3 which for the object of virtually no width would mean almost infinite scale up.
Now this makes sense!

Thanks
Norbert
Reply With Quote
  #17  
Old 03-05-2010, 05:26
lnfagf
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by wOxxOm View Post

Code:
Sub ChangeLineLenConst()
   const Delta# = -3
   Dim L As Shape, length#, ratio#

   If ActiveShape Is Nothing Then Exit Sub

   ActiveDocument.Unit = cdrMillimeter
   ActiveDocument.ReferencePoint = cdrCenter
   
   Set L = ActiveShape
   length = Sqr(L.SizeWidth ^ 2 + L.SizeHeight ^ 2)
   
   If length + delta > 0 Then
      ratio = (length + delta) / length
      L.SetSize L.SizeWidth * ratio, L.SizeHeight * ratio
   End If
End Sub
Just curious is this formula for length works even with odd shaped objects? How did you arrive with -3 for delta?
Reply With Quote
  #18  
Old 03-05-2010, 05:41
wOxxOm's Avatar
wOxxOm wOxxOm is offline
Senior Member
 
Join Date: Mar 2005
Posts: 836
Default

read the thread starting from the first post :p
as for line length use Shape.Curve.Length
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
How to draw a double line in coreldraw? 4gold General 11 01-11-2005 19:39
Contour Cut Line for Digital prints GraphiXtreme New product ideas 2 26-08-2005 16:28
Reading Font Properties from selected text in CD9 sherman01 CorelDRAW/Corel DESIGNER VBA 2 24-11-2004 08:59
Length of line pragatipc SecuriDesign 1 18-08-2004 21:23
Calculate total length of line or path pmills New product ideas 2 08-12-2003 05:52


All times are GMT -5. The time now is 04:43.


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