Skip to content

Commit

Permalink
Merge pull request #1256 from mcneel/kike/1.x
Browse files Browse the repository at this point in the history
Generate a transaction name with the file name.
  • Loading branch information
kike-garbo authored Dec 18, 2024
2 parents 1b8f3b2 + 6dd49c4 commit 4fca2a9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
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

0 comments on commit 4fca2a9

Please sign in to comment.