-
-
Notifications
You must be signed in to change notification settings - Fork 335
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
Error / chart.draw() #405
Comments
Would you please share the script here? I can help you better that way. Thanks |
import sys
sys.path.append('''C:\Users\bob1333\AppData\Roaming\pyRevit-Master\pyrevitlib''')
#from pyrevit.loader import sessionmgr
#sessionmgr.load_session()
from pyrevit import script
output = script.get_output()
# Pie chart
chart = output.make_pie_chart()
chart.set_style('height:150px')
chart.options.title = {'display': True,
'text': 'Chart Title',
'fontSize': 18,
'fontColor': '#000',
'fontStyle': 'bold'}
# Set the labels for the circumference axis
chart.data.labels = ['A', 'B', 'C']
# Create new data sets
set_a = chart.data.new_dataset('set_a')
set_a.data = [100, 20, 50]
# You can set a different color for each pie of the chart
set_a.backgroundColor = ["#560764", "#1F6CB0", "#F98B60"]
set_b = chart.data.new_dataset('set_b')
set_b.data = [50, 30, 80]
set_b.backgroundColor = ["#913175", "#70A3C4", "#FFC057"]
set_c = chart.data.new_dataset('set_c')
set_c.data = [40, 20, 10]
set_c.backgroundColor = ["#DD5B82", "#E7E8F5", "#FFE084"]
chart.randomize_colors()
chart.draw() |
Remove import sys
from pyrevit import script
output = script.get_output()
# Pie chart
chart = output.make_pie_chart()
# chart.set_style('height:150px')
chart.options.title = {'display': True,
'text': 'Chart Title',
'fontSize': 18,
'fontColor': '#000',
'fontStyle': 'bold'}
# Set the labels for the circumference axis
chart.data.labels = ['A', 'B', 'C']
# Create new data sets
set_a = chart.data.new_dataset('set_a')
set_a.data = [100, 20, 50]
# You can set a different color for each pie of the chart
set_a.backgroundColor = ["#560764", "#1F6CB0", "#F98B60"]
set_b = chart.data.new_dataset('set_b')
set_b.data = [50, 30, 80]
set_b.backgroundColor = ["#913175", "#70A3C4", "#FFC057"]
set_c = chart.data.new_dataset('set_c')
set_c.data = [40, 20, 10]
set_c.backgroundColor = ["#DD5B82", "#E7E8F5", "#FFE084"]
chart.randomize_colors()
chart.draw() |
Hi thanks for replying so fast ! I changed the code but i still get the same error: I have the feeling I am not importing the pyrevit module right ....maybe there is something funny with the path idk.... I get the same error even with the most simple chart import sys from pyrevit import script |
Why are you adding the pyrevitlib path to the sys.paths? It's already added by pyRevit when running the tool. This works fine. from pyrevit import script
output = script.get_output()
chart = output.make_bubble_chart()
set_a = chart.data.new_dataset('set_a')
set_a.data = [{'x': 1, 'y': 12, 'r': 33},
{'x': 2, 'y': 9, 'r': 60},
{'x': 3, 'y': 4, 'r': 34},
{'x': 4, 'y': 22, 'r': 22}]
chart.draw() |
Otherwise i get the error; |
Are you running this in a pyRevit tool or RevitPythonShell? |
in RevitPythonShell |
pyRevit charts is for pyRevit and depends on the output window (html renderer) to render the chart. Make a pyRevit tool, throw your script in it and run. |
Resolved setting style issue with charts. Will push in 4.6.6 this weekend |
ahhhhhh ok thanks a lot ! |
Hi ! tried to repicate the code on your blog (https://eirannejad.github.io/pyRevit/pyrevit/update/2017/03/07/charts.html) that allows one to draw drifferent charts and it works perfectly untill I try to draw the chart ( chart.draw()) then i get this error:
Exception : System.MissingMemberException: 'NoneType' object has no attribute 'Document'
at Microsoft.Scripting.Interpreter.ThrowInstruction.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run3[T0,T1,T2,TRet](T0 arg0, T1 arg1, T2 arg2)
at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
at IronPython.Compiler.Ast.DynamicGetMemberExpression.GetMemberInstruction.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
at IronPython.Runtime.Method.MethodBinding.SelfTarget(CallSite site, CodeContext context, Object target)
at IronPython.Compiler.Ast.CallExpression.Invoke0Instruction.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
at IronPython.Runtime.Method.MethodBinding.SelfTarget(CallSite site, CodeContext context, Object target)
at IronPython.Compiler.Ast.CallExpression.Invoke0Instruction.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
at IronPython.Runtime.Method.MethodBinding.SelfTarget(CallSite site, CodeContext context, Object target)
at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
at Microsoft.Scripting.Interpreter.FuncCallInstruction
5.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.LightLambda.Run3[T0,T1,T2,TRet](T0 arg0, T1 arg1, T2 arg2) at IronPython.Compiler.Ast.CallExpression.Invoke0Instruction.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1) at IronPython.Runtime.Method.MethodBinding.SelfTarget(CallSite site, CodeContext context, Object target) at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1) at Microsoft.Scripting.Interpreter.DynamicInstruction
3.Run(InterpretedFrame frame)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 Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope scope)
at Microsoft.Scripting.Hosting.ScriptSource.ExecuteAndWrap(ScriptScope scope, ObjectHandle& exception)
Any ideas why it might be ?
I tried running the script in Revit19 with you latest pyRevit version on an win10 and the pyRevit 4.5 on Revit17 and i get the same error every time ?
I would very much appreciate your help !
The text was updated successfully, but these errors were encountered: