# How to scale line width with object resizing

This post is a wiki. Anyone with karma >75 is welcome to improve it.

I created an object in a line drawing form. When resized the image to about half the size I originally drew it the line width of the object did not scale down with the drawing. Is there a way to tell LibreDraw to scale line widths with the resizing of an object?

edit retag close merge delete

Sort by » oldest newest most voted

No, that is not possible with drawing objects from Draw, because transformations do not affect the line width. That is one of the differences between objects by Draw and SVG-objects.

You can workaround this, if you generate a SVG-object from your drawing before resizing (File > Export; check Selection) and then use the SVG-object instead of the original drawing.

Some other ideas for workarounds: Use a common style, that you only need to adapt the line width in one place. Or do not use thick lines, but tread the lines as filled objects. That is what you get by "Convert to Contour".

more

(I do not understand what you mean by "line drawing form" or "the image" in the context.)

There is no way to define a truely relative line width relating to whatever size property, and no tool to scale the line width on resizing.

If you urgently want such scaling, you will need to create user code. This would not be exactly simple. To do auomatic scaling while resizing with the mouse may be specifically difficult and would most likely not result in reversible processes.

A more practicable way might be to set a new (absolute) line width relating to some overall size of a shape as it currently is. Problems of a different kind will arise if you want to apply the new method to GroupShape or ShapeCollection objects.

A first sketch of user code doing code as decribed for a single ungrouped shape:

Sub setLineWidthRelativeToDiagonal()
tSC   = ThisComponent.CurrentSelection
last  = tSc.Count - 1
j = -1
relLw = 1 * InputBox("Enter theRatio:", "LineWidth / TotalSize", "0.01")
' You are prompted for the input in advance of testing if it is applicable
' to any selected shape.
Do While j<last
j = j + 1
tSh = tSC(j)
If NOT tSh.SupportsService("com.sun.star.drawing.Shape")      Then Goto notApplicable
If     tSh.SupportsService("com.sun.star.drawing.GroupShape") Then Goto notApplicable
With tSh.Size
dX  = .Width
dY  = .Height
End With
totalSize          = Sqr(dX*dX + dY*dY)
newLw              = totalSize *relLw
resizeRat          = newLw / tSh.LineWidth
tSh.LineWidth      = newLw
tSh.LineStartWidth = tSh.LineStartWidth*resizeRat
tSh.LineEndWidth   = tSh.LineEndWidth*resizeRat
notApplicable:
Loop
End Sub

more

Another workaround for easy handling (no export as svg file) is:

Copy/cut the shape and then insert (Paste Special) as GDI. The lines will be scaled as well as the entire shape.

The disadvantage is that the format will change; GDI can be edited but has lost some possiblities of editing in comparison to "native" Draw objects.

more