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

Duplicate schedule name with import from CSV makes pyrevit error #968

Closed
DuncanLithgow opened this issue Aug 12, 2020 · 8 comments
Closed
Labels
Enhancement Enhancement request [class->Improved #{number}: {title}]

Comments

@DuncanLithgow
Copy link

Describe the bug
Trying to import a csv as a wall key schedule because the first try looks all wrong

To Reproduce
Import the same csv to the same category twice

Expected behavior
pyRevit should create a new schedule with an iteration in the name. For example

  • ScheduleFromCVS
  • ScheduleFromCSV(2)

Desktop (please complete the following information):

  • OS: Win10
  • pyRevit Version pyRevit 4.7.6:277:2020.2
  • pyRevit Environment: Open a command prompt and run the command below. Replace these lines with the results. Take a look at this markdown guide and wrap the command results in ``` when pasting here for correct formatting.
(c) 2018 Microsoft Corporation. All rights reserved.

```C:\Users\xxx>pyrevit env
==> Registered Clones (full git repos)
==> Registered Clones (deployed from archive/image)
master | Deploy: "basepublic" | Branch: "master" | Version: "4.7.6" | Path: "C:\Users\dli\AppData\Roaming\pyRevit-Master"
==> Attachments
master | Product: "Autodesk Revit 2020" | Engine: 277 | Path: "C:\Users\dli\AppData\Roaming\pyRevit-Master" | Manifest: "C:\Users\dli\AppData\Roaming\Autodesk\Revit\Addins\2020\pyRevit.addin"
master | Product: "2019.2.2 Hotfix" | Engine: 277 | Path: "C:\Users\dli\AppData\Roaming\pyRevit-Master" | Manifest: "C:\Users\dli\AppData\Roaming\Autodesk\Revit\Addins\2019\pyRevit.addin"
master | Product: "2018.3.3 Security Fix" | Engine: 277 | Path: "C:\Users\dli\AppData\Roaming\pyRevit-Master" | Manifest: "C:\Users\dli\AppData\Roaming\Autodesk\Revit\Addins\2018\pyRevit.addin"
master | Product: "2017.2.5 Security Fix" | Engine: 277 | Path: "C:\Users\dli\AppData\Roaming\pyRevit-Master" | Manifest: "C:\Users\dli\AppData\Roaming\Autodesk\Revit\Addins\2017\pyRevit.addin"
==> Installed Extensions
==> Default Extension Search Path
C:\Users\dli\AppData\Roaming\pyRevit\Extensions
==> Extension Search Paths
==> Extension Sources - Default
https://github.com/eirannejad/pyRevit/raw/master/extensions/extensions.json
==> Extension Sources - Additional
==> Installed Revits
Autodesk Revit 2021 | Version: 21.1.0.108 | Build: 20200708_1515(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2021"
Autodesk Revit 2020 | Version: 20.2.20.31 | Build: 20200426_1515(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2020"
2019.2.2 Hotfix | Version: 19.2.20.24 | Build: 20190808_0900(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2019"
2018.3.3 Security Fix | Version: 18.3.3.18 | Build: 20190510_1515(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2018"
2017.2.5 Security Fix | Version: 17.0.1169.0 | Build: 20190508_0315(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2017"
==> Running Revit Instances
Error: Object reference not set to an instance of an object.
Run with "--debug" option to see debug messages```

**Additional context**
Here's the console text

```ERROR [pyrevit.revit.db.transaction] Error in Transaction Context. Rolling back changes. | <type 'exceptions.Exception'>:Name must be unique. 
Parameter name: name

IronPython Traceback:
Traceback (most recent call last):
 File "C:\Users\dli\AppData\Roaming\pyRevit-Master\extensions\pyRevitTools.extension\pyRevit.tab\Drawing Set.panel\views.stack\Schedules.pulldown\Create Schedule from CSV.pushbutton\script.py", line 160, in <module>
 File "C:\Users\dli\AppData\Roaming\pyRevit-Master\extensions\pyRevitTools.extension\pyRevit.tab\Drawing Set.panel\views.stack\Schedules.pulldown\Create Schedule from CSV.pushbutton\script.py", line 36, in create_key_schedule
Exception: Name must be unique.
Parameter name: name

Script Executor Traceback:
Autodesk.Revit.Exceptions.ArgumentException: Name must be unique.
Parameter name: name
 at Microsoft.Scripting.Interpreter.ThrowInstruction.Run(InterpretedFrame frame)
 at Microsoft.Scripting.Interpreter.Interpreter.HandleException(InterpretedFrame frame, Exception exception)
 at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
 at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
 at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx)
 at PyRevitLabs.PyRevit.Runtime.IronPythonEngine.Execute(ScriptRuntime& runtime)```

eirannejad added a commit that referenced this issue Aug 15, 2020
@eirannejad
Copy link
Collaborator

Fixed and will be published with next release

@DuncanLithgow
Copy link
Author

of course the schedule might already be on a sheet, so even better would be if it asks whether it should overwrite or create a new schedule.

@eirannejad
Copy link
Collaborator

So the tool creates Key schedules. You can't have two key schedules feeding values to the same parameters. Only one can exist

@DuncanLithgow
Copy link
Author

Okay, sure. But is there is no way to replace the previous data with new data in the same schedule?

@eirannejad
Copy link
Collaborator

Great question. I need to look at the api. I just understood what your problem is. You have a schedule on a sheet that you don't want to delete every time there is new data. Got it! Sorry I'm a bit all over the place these days working on so many different things.

@eirannejad
Copy link
Collaborator

  • Okay the API supports removing rows in key schedules. I'll implement that and will rework the schedule conflict resolution logic

@eirannejad eirannejad reopened this Aug 17, 2020
@eirannejad eirannejad added Enhancement Enhancement request [class->Improved #{number}: {title}] and removed Under Review labels Aug 17, 2020
@DuncanLithgow
Copy link
Author

Brilliant! I look forward to seeing it sometime when someone submits a patch.

eirannejad added a commit that referenced this issue Aug 20, 2020
@eirannejad
Copy link
Collaborator

Fixed and will be published with next release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Enhancement request [class->Improved #{number}: {title}]
Projects
None yet
Development

No branches or pull requests

2 participants