Skip to content

Improved Paper Space Layout management - #1096

Closed
simonedd wants to merge 3 commits into
DomCR:masterfrom
simonedd:layout-management
Closed

Improved Paper Space Layout management#1096
simonedd wants to merge 3 commits into
DomCR:masterfrom
simonedd:layout-management

Conversation

@simonedd

Copy link
Copy Markdown
Contributor

Description

Follow-up of PR #1086

  • When removing a layout, the check on default layout is based on the BlockRecord name and the AssociatedBlock is removed from the Document.BlockRecords collection.
  • When adding a layout, the default *Paper_SpaceN block name is assigned to the AssociatedBlock.

@DomCR
DomCR self-requested a review June 11, 2026 08:26
Comment thread src/ACadSharp/Objects/Layout.cs
public override void Add(Layout entry)
{
if (!isDefaultLayout(entry))
entry.AssociatedBlock.Name = findSmallestFreePaperSpaceName(this._dictionary.Document);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think is necessary to change the name of the block, I know that the standard has to be named PaperSpace(number) but after the first one, the others don't seem to effect the output.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's not required. DWG files are still valid, though.

layout.AssociatedBlock.Name.Equals(BlockRecord.ModelSpaceName, StringComparison.InvariantCultureIgnoreCase);
}

private static string findSmallestFreePaperSpaceName(CadDocument doc)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method could be a public method for the user to assign the next valid name to the layout block.

Another option could be to implement the method CreateLayout in the collection which it will add a layout with the valid name and return the result.

@DomCR

DomCR commented Jun 11, 2026

Copy link
Copy Markdown
Owner

Apologize for the delayed review.

@simonedd

Copy link
Copy Markdown
Contributor Author

While working on this I realized that proper paper-space layout management is a larger, interconnected task than what this PR covers. Should probably be done as one coherent effort.
I've also solved my underlying issue without needing changes to ACadSharp, so there's no urgency on my side.

Is there anything here you'd want to keep? Otherwise I'm happy to close it. Let me know what you prefer.

@DomCR

DomCR commented Jun 22, 2026

Copy link
Copy Markdown
Owner

I agree that the Layouts have a tight coupling with the Associated block which causes a rise of complexity we can close this one and I'll take a look on that relationship between blocks and layouts.

Thanks for the help!

@simonedd simonedd closed this Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants