Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate a transaction name with the file name. #1256

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ ref string message
{
using (var transGroup = new TransactionGroup(app.ActiveUIDocument.Document))
{
transGroup.Start(Path.GetFileNameWithoutExtension(definition.Properties.ProjectFileName));
transGroup.Start(definition.GetTransactionName());

definition.NewSolution(expireAllObjects: true);

Expand Down Expand Up @@ -550,7 +550,7 @@ ref string message
// {
// using (var transGroup = new TransactionGroup(app.ActiveUIDocument.Document))
// {
// transGroup.Start(Path.GetFileNameWithoutExtension(definition.Properties.ProjectFileName));
// transGroup.Start(definition.GetTransactionName());

// GH_Document.EnableSolutions = true;
// definition.Enabled = true;
Expand Down
12 changes: 12 additions & 0 deletions src/RhinoInside.Revit.External/Extensions/Grasshopper.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
using System;
using System.IO;
using Grasshopper.Kernel;

namespace Grasshopper
{
internal static class GH_DocumentExtension
{
public static string GetTransactionName(this GH_Document document)
{
var displayName = string.Empty;
if (document.Properties.ProjectFileName is object) displayName = Path.GetFileNameWithoutExtension(document.Properties.ProjectFileName).TripleDot(24).Replace("_", " ").Replace("-", " ");
if (string.IsNullOrEmpty(displayName) && document.FilePath is object) displayName = Path.GetFileNameWithoutExtension(document.FilePath).TripleDot(24).Replace("_", " ").Replace("-", " ");
if (string.IsNullOrEmpty(displayName)) displayName = $"Grasshopper {DateTime.Now.ToString(System.Globalization.CultureInfo.CurrentUICulture)}";

return displayName.ToControlEscaped();
}

public static bool KeepOpen(this GH_Document document)
{
#if RHINO_8
Expand Down
6 changes: 2 additions & 4 deletions src/RhinoInside.Revit/GH/Guest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -703,10 +703,8 @@ GH_Document NewSolution()

internal void StartTransactionGroups()
{
var now = DateTime.Now.ToString(System.Globalization.CultureInfo.CurrentUICulture);
var name = ActiveDocumentStack.Peek().DisplayName;

StartTransactionGroups($"Grasshopper {now}: {name.TripleDot(16)}", true);
var name = ActiveDocumentStack.Peek().GetTransactionName();
StartTransactionGroups(name, true);
}

internal void StartTransactionGroups(string name, bool forcedModal)
Expand Down
Loading