Code Monkey home page Code Monkey logo

Comments (4)

pilcru avatar pilcru commented on September 14, 2024

from ghpythonremote.

r-yu52 avatar r-yu52 commented on September 14, 2024

Thank you for your quick reply!

I did what you suggest, but it shows another warning:

_Runtime error (Exception): type() argument 1 must be string, not unicode

Traceback:
  line 102, in value, "C:\Users\20204895\AppData\Roaming\McNeel\Rhinoceros\7.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rpyc\core\async_.py"
  line 469, in sync_request, "C:\Users\20204895\AppData\Roaming\McNeel\Rhinoceros\7.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rpyc\core\protocol.py"
  line 76, in syncreq, "C:\Users\20204895\AppData\Roaming\McNeel\Rhinoceros\7.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rpyc\core\netref.py"
  line 253, in __call__, "C:\Users\20204895\AppData\Roaming\McNeel\Rhinoceros\7.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rpyc\core\netref.py"
  line 18, in script_

line 18 is : q = sp.symbols('q', cls=Function)

I'm not sure if it's the problem with python 2.7, since it works well with python 3.0

from ghpythonremote.

pilcru avatar pilcru commented on September 14, 2024

from ghpythonremote.

pilcru avatar pilcru commented on September 14, 2024

Hi @r-yu52, sorry it's been a while since you asked for help on this but I've been doing some cleaning around here and just looked at it again today.

From what I can tell, I can properly run sympy functionalities from Grasshopper, as long as all strings sent to it are bytes strings. (And of course, imports need to be properly defined in each of the GHPython scripts you run.) The code below gives the expected result:

import scriptcontext as sc
sp = sc.sticky['sympy']

x = sp.symbols(b'x')
q = sp.symbols(b'q', cls=sp.Function)
Mq = sp.symbols(b'Mq', cls=sp.Function)
Vq = sp.symbols(b'Vq', cls=sp.Function)
l = sp.symbols(b'l')  # Symbol l was not defined

diffeqbmq = sp.Eq(Mq(x).diff(x, x), -q(x))  # -q is not valid, symbolic functions need to be instantiated: -q(x)
BMq = sp.dsolve(diffeqbmq, Mq(x), ics={Mq(0): 0, Mq(l): 0})
SFq = sp.Eq(Vq(x), BMq.rhs.diff(x))

print(BMq, SFq)

Note that your original code had a couple of additional errors that prevented it from working, even outside in regular CPython, see the comments in the code.

from ghpythonremote.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.