There is a problem drawing corners with code in Layout

path = 'C:\Users\admin\Desktop\无标题.layout'
doc = path
start_p =,
r, a =, * Math.sqrt(2)
p1 =  start_p + * 2, 0)
p2 =  start_p +, -a)
new_path =, p2)
doc.add_entity new_path, doc.layers.first, doc.pages.first
new_path =, p2)
doc.add_entity new_path, doc.layers.first, doc.pages.first path

Use append_point and close.
Avoid closed point is the inflection point.

start_p =,
r, a =, * Math.sqrt(2)
center = start_p +, 0)
p1 = start_p +, -a)
p2 = start_p + * 2, 0)
new_path =, start_p)
new_path.append_point p1
new_path.append_point p2
new_path.append_point center
doc.add_entity new_path, doc.layers.first, doc.pages.first

You can also control the type of join and end caps for Layout::Path objects.
They are a subclass of Layout::Entity so they also have a style getter and style= setter.

The Layout::Style class has join type constants:
… also stroke pattern (stipple) style and end cap style constants.

For example …

path_style =
path_style.stroke_join_style= Layout::Style::JOIN_STYLE_ROUND
path_style.stroke_cap_style= Layout::Style::CAP_STYLE_ROUND

# Might need to set the modified style back to the entity: path_style

@tt_su Do mods to an Layout::Entity's style manifest immediately ?

Not sure, I need to check.

I asked internally. The response:

You must set the style on the entity. The style object received is a copy.
To be more technical than is necessary, the style object is created at the time of request and is never owned by the entity in the first place.


Thank you Thomas, this is as I had thought (and surmised in the above code comment.)

I drew two lines before. This situation of two lines should not be handled.