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

Error / chart.draw() #405

Closed
bob13333 opened this issue Nov 3, 2018 · 11 comments
Closed

Error / chart.draw() #405

bob13333 opened this issue Nov 3, 2018 · 11 comments

Comments

@bob13333
Copy link

bob13333 commented Nov 3, 2018

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.FuncCallInstruction5.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.DynamicInstruction3.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 !

@eirannejad
Copy link
Collaborator

Would you please share the script here? I can help you better that way. Thanks

@bob13333
Copy link
Author

bob13333 commented Nov 6, 2018

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()

@eirannejad
Copy link
Collaborator

Remove chart.set_style('height:150px') and the code works. I'll fix the set style issue

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()

@bob13333
Copy link
Author

bob13333 commented Nov 6, 2018

Hi thanks for replying so fast ! I changed the code but i still get the same error:
Exception : System.MissingMemberException: 'NoneType' object has no attribute 'Document'

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
sys.path.append('''C:\Users\Name\AppData\Roaming\pyRevit-Master\pyrevitlib''')

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()

@eirannejad
Copy link
Collaborator

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()

@bob13333
Copy link
Author

bob13333 commented Nov 6, 2018

Otherwise i get the error;
Exception : IronPython.Runtime.Exceptions.ImportException: No module named pyrevit
....

@eirannejad
Copy link
Collaborator

Are you running this in a pyRevit tool or RevitPythonShell?

@bob13333
Copy link
Author

bob13333 commented Nov 6, 2018

in RevitPythonShell

@eirannejad
Copy link
Collaborator

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.

eirannejad added a commit that referenced this issue Nov 6, 2018
@eirannejad
Copy link
Collaborator

Resolved setting style issue with charts. Will push in 4.6.6 this weekend

@bob13333
Copy link
Author

bob13333 commented Nov 6, 2018

ahhhhhh ok thanks a lot !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants