#1




Length of a selected line
Hi all,
I have a selected line. What I need to do is reduce the length of the line by 3mm, its reference point beng centre. Can any of you'll direct me to a thread here or any suggestions? Cheers Norbert 
#2




something like this:
Code:
function ChangeLineLen(L as shape, byval delta as double) as boolean dim length as double, ratio as double length=sqr(L.sizewidth^2+L.sizeheight^2) if length+delta=0 then exit function ' returns false  error: line would be reduced to singularity ratio=length/(length+delta) L.SetSize L.sizeWidth*ratio, L.sizeHeight*ratio ChangeLineLen=true end function 
#3




Hi,
Thanks for you r response. I should have actually mentioned that I am not at all familiar with VBA and I am at the moment attempting it. I have not reached the stage where I can create functions and then call these functions. Can you explain the same using a subroutine? I would appreciate if you could keep it simple or if you could provide each line with a comment? I know this is asking for too much but I would sincerely appreciate it and would enable me to understand the code rather than simply copying it and pasting it. Thanking you in advance Norbert 
#4




Code:
Sub ChangeLineLen() Static prevDelta As Double Dim L As Shape, delta As Double Dim length As Double, ratio As Double, s As String If ActiveShape Is Nothing Then Exit Sub ActiveDocument.Unit = cdrCentimeter ActiveDocument.ReferencePoint = cdrCenter Set L = ActiveShape length = Sqr(L.SizeWidth ^ 2 + L.SizeHeight ^ 2) s = InputBox("Current length: " + FormatNumber(length, 3), "Change line length by: ", CStr(prevDelta)) If Not IsNumeric(s) Then Exit Sub delta = CDbl(s) prevDelta = delta If length + delta > 0 Then ratio = (length + delta) / length L.SetSize L.SizeWidth * ratio, L.SizeHeight * ratio End If End Sub :) actually there's no big need to comment on this, at least I see none. However a few tips  to learn better what's happening use F8 to trace the code line by line and lookup values of variables etc (hover mouse over in VBA Editor). Also a great source of info is rightclick symbol and choose 'Definition' or F1 key is the saviour! 
#5




Thank you very very very much!
I sincerely appreciate this! Cheers! Norbert 
#6




Length of Line
Hi,
In your code, suppose I don't want the input message box? I simply want the length of the original selection to be reduced by 3mm. Appreciate your help. Thanks in advance. Norbert 
#7




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 Last edited by wOxxOm; 15042007 at 22:24. 
#8




Nothing happenning
Hi!
Unfortunately this piece of code does nothing! The line is left untouched! Thanks Norbert 
#9




poor me, that ought be millimeter and I wrote millimIter :)

#10




Thank You
Thank you very much!!
This works like a charm. Would you be able to explain something to me please? I tried using Curve.Length in a message Box and it displayed the length of the line perfectly for both horizontal lines and vertical lines. However when I tried a setSize Curve.length3, it workied perfectly for horizontal lines but the vertical lines actually increased rather than decrease and not even by 3. Appreciate your help! Norbert 
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 
How to draw a double line in coreldraw?  4gold  General  11  01112005 19:39 
Contour Cut Line for Digital prints  GraphiXtreme  New product ideas  2  26082005 16:28 
Reading Font Properties from selected text in CD9  sherman01  CorelDRAW/Corel DESIGNER VBA  2  24112004 08:59 
Length of line  pragatipc  SecuriDesign  1  18082004 21:23 
Calculate total length of line or path  pmills  New product ideas  2  08122003 05:52 