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

Wish: Access Dynamo's Package Paths from Python #71

Closed
mostaphaRoudsari opened this issue Jul 15, 2016 · 17 comments
Closed

Wish: Access Dynamo's Package Paths from Python #71

mostaphaRoudsari opened this issue Jul 15, 2016 · 17 comments
Labels
Python Python improvements Tracked Items that are tracked internally on the development boards

Comments

@mostaphaRoudsari
Copy link

Following up from this discussion on the forum.

I'm looking for a call from inside python node to access package path(s)? It will save me an other developers who are loading the libraries from package folder a lot of duplicated code and also ensures that we can have access to the libraries even if the user installs them in a custom folder.

cc: @mjkkirschner
labels: wish, python

@andydandy74
Copy link

@mostaphaRoudsari - Great idea. In the meantime, have a look at how this was solved for BumbleBee package: ksobon/Bumblebee#15

@Amoursol
Copy link
Contributor

Hello @mostaphaRoudsari,

We don't currently have a stable way to access the Dynamo document to pull the Package Directories path (i.e part of the DynamoServices.dll) - but you can do so, at risk and unsupported, in the following way:

# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference(‘DynamoRevitDS’)
from Dynamo.Applications import *

packageDir = list(DynamoRevit.RevitDynamoModel.PathManager.PackagesDirectories)[0]
OUT = packageDir

@mostaphaRoudsari
Copy link
Author

Hi @Amoursol, This is very helpful. Can you tell me what are the possible risks involved? Also do I need a specific minimum version of Dynamo for this to work?

@Amoursol
Copy link
Contributor

@mjkkirschner or @QilongTang would be better suited to answer this question 😊

@QilongTang
Copy link

@mostaphaRoudsari @Amoursol Traced back, it was added five years ago, so pretty much all major versions we are supporting right now, 1.3.x and 2.x.x

@mostaphaRoudsari
Copy link
Author

Thank you @QilongTang. One follow up question. I assume this will not work in Dynamo-core (is this what you call it?). Or is there a similar call that I can use to get the packages in DynamoCore?

The differences between DynamoRevit and DynamoCore has been an issue for us.

@mjkkirschner
Copy link
Member

mjkkirschner commented Jan 27, 2020

What is risky is by accessing a property of the application during graph execution it's not guaranteed to be up to date - it's also not expected that these package directories would ever be modified during graph execution... Only on from the UI or from an extension etc.

It will work for DynamoRevit only - the reason it works is becasue DynamoRevit.DynamoRevitModel is static - in all honesty, it likely should not be.

@mjkkirschner
Copy link
Member

The better solution here is for us to add an API to dynamoServices which is safe to consume from a node - likely just the getter for the package directories, which would be accessible easily during graph execution from any node by referencing a static property in DynamoServices.

@mostaphaRoudsari
Copy link
Author

Hi @mjkkirschner, I prefer to wait for the second solution which should work for both DynamoRevit and DynamoCore. @Amoursol if this is something that you can include in an upcoming release we will be happy to test it for you.

This will also help us to do a new release of our Dynamo packages so at least they work as they are.

@Amoursol
Copy link
Contributor

Hello @mostaphaRoudsari - This has been added to our backlog.

@mjkkirschner
Copy link
Member

Please see related PR.

@mostaphaRoudsari
Copy link
Author

@mjkkirschner, thanks. Do we know from which version of Dynamo this will be available?

@mjkkirschner
Copy link
Member

as of now, this code has been merged to trunk which is currently 2.8.

@Amoursol
Copy link
Contributor

Hello @mostaphaRoudsari - Have you had a chance to check this in a daily build?

@mikkelvangsgaard
Copy link

Hi, any updates on this?

thanks

@Amoursol
Copy link
Contributor

Hello @mikkelvangsgaard - This is now part of Dynamo 2.8 😄

@mikkelvangsgaard
Copy link

Great! Thank you @Amoursol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Python Python improvements Tracked Items that are tracked internally on the development boards
Projects
Status: Done
Development

No branches or pull requests

7 participants