Isotropix Forums

Help with python imports needed :)

Clarisse Scripting related topics

Help with python imports needed :)

Unread postby atnreg » Thu May 09, 2019 2:03 pm

Hi!

I have been doing Python scripts for Clarisse quite a lot and they work in Clarisse but I would like to be able to use the linting and other editor (VSCode) features :)

I read here in the forum about some import issues but it was gui vs. standalone so it is different so I decided to start new topic ;)

The problem is:
In my code, I do
import ix
or
import ix_helper as ix

Otherwise those work but linter says it cannot find ix.api (used in code like class myclass(ix.api.ModuleScriptedClassEngine) and many others).
That is understandable because there is no such import inside the ix.py nor ix_helper.py but still the code works in Clarisse :D

So what exactly do I need to import so that I get same module structure in VSCode as Clarisse when it runs code?
Actually, for Clarisse only (script editor) I don't need to import anything so please tell me what Clarisse imports when it runs the scripts?

I understand it is still different but it would help a lot if I could benefit from the great developer tools in VSCode which I currently can't because of this problem.

Any ideas? :mrgreen:

Thank you!

Antti
Antti
AMD Ryzen Threadripper 2990wx (32c/64t),64GB RAM,NVIDIA GTX 1080ti,Win10
Clarisse 4.0SP1(2,2b crash with optix),Blender,Fusion360,Houdini,ZBrush,Onyx,SubstPnt...
Started: Clarisse 2016/10 (Py 2017/01), Python 2016/11
No business, just fun :)
atnreg
 
Posts: 482
Joined: Mon Sep 19, 2016 4:20 pm
Location: Helsinki, Finland

Re: Help with python imports needed :)

Unread postby bvaldes » Thu May 09, 2019 3:53 pm

Hi,

Inside of Clarisse, you don't need to import ix because it's already imported.
I took a look to the ix_helper file and it looks like you can't import ix_helper as ix because ix_helper import ix as ix. So if you want to import ix through ix_helper, you have to do like so:

python code

import ix_helper
ix = ix_helper.ix

You will not be able to get the auto-completion inside of VSCode because the linter doesn't success to resolve what happen in ix_helper but it works perfectly.

I tried in VSCode and by using the workaround above, the linter doesn't tell there is an issue but the auto-complete can't be resolved.
I can't tell you more on my side because I don't succeed to have better result. You should ask to the python for VSCode github if it's normal that it can't resolve this.

I hope this is what you are looking for and I succeed to help you.

Best regards
Benoit VALDES
Isotropix
Clarisse QA
User avatar
bvaldes
 
Posts: 384
Joined: Mon Sep 26, 2016 10:44 am

Re: Help with python imports needed :)

Unread postby atnreg » Thu May 09, 2019 4:38 pm

Hi!

Yes! Now the linter does not give errors :mrgreen:

Thank you very much, once again!

BTW, which code editor do you use when developing Clarisse Python code? :)

Antti
Antti
AMD Ryzen Threadripper 2990wx (32c/64t),64GB RAM,NVIDIA GTX 1080ti,Win10
Clarisse 4.0SP1(2,2b crash with optix),Blender,Fusion360,Houdini,ZBrush,Onyx,SubstPnt...
Started: Clarisse 2016/10 (Py 2017/01), Python 2016/11
No business, just fun :)
atnreg
 
Posts: 482
Joined: Mon Sep 19, 2016 4:20 pm
Location: Helsinki, Finland

Re: Help with python imports needed :)

Unread postby sam » Thu May 09, 2019 4:39 pm

Personally, the script editor
Sam Assadian
Isotropix
CEO/Founder
User avatar
sam
 
Posts: 1377
Joined: Fri Jan 25, 2013 11:33 pm

Re: Help with python imports needed :)

Unread postby atnreg » Thu May 09, 2019 4:42 pm

sam wrote:Personally, the script editor


Oh :o Well, you know your own code so well you don't need code completion or other tools like that :mrgreen:

Antti
Antti
AMD Ryzen Threadripper 2990wx (32c/64t),64GB RAM,NVIDIA GTX 1080ti,Win10
Clarisse 4.0SP1(2,2b crash with optix),Blender,Fusion360,Houdini,ZBrush,Onyx,SubstPnt...
Started: Clarisse 2016/10 (Py 2017/01), Python 2016/11
No business, just fun :)
atnreg
 
Posts: 482
Joined: Mon Sep 19, 2016 4:20 pm
Location: Helsinki, Finland

Re: Help with python imports needed :)

Unread postby sam » Thu May 09, 2019 4:44 pm

in the script editor, type "ix." (then CTRL + Space)... Voilà
Sam Assadian
Isotropix
CEO/Founder
User avatar
sam
 
Posts: 1377
Joined: Fri Jan 25, 2013 11:33 pm

Re: Help with python imports needed :)

Unread postby atnreg » Thu May 09, 2019 5:00 pm

sam wrote:in the script editor, type "ix." (then CTRL + Space)... Voilà


OOOOOPS :shock: :oops:

I didn't know that and I HAVE read the manual thoroughly (when I started with Clarisse), is that relatively new feature?

Anyway, that's great, thanks :)
I think I'll still continue with VSCode but I might need to do some comparison, especially on code completion :mrgreen:

Antti
Antti
AMD Ryzen Threadripper 2990wx (32c/64t),64GB RAM,NVIDIA GTX 1080ti,Win10
Clarisse 4.0SP1(2,2b crash with optix),Blender,Fusion360,Houdini,ZBrush,Onyx,SubstPnt...
Started: Clarisse 2016/10 (Py 2017/01), Python 2016/11
No business, just fun :)
atnreg
 
Posts: 482
Joined: Mon Sep 19, 2016 4:20 pm
Location: Helsinki, Finland

Re: Help with python imports needed :)

Unread postby bvaldes » Fri May 10, 2019 9:07 am

Hi,

That was a hidden feature and we release it with 4.0 I guess. For Clarisse I use VSCode and Script editor.
For vscode I've done a plugin (I am not a js dev so I've found a way to launch python code from JS ahahaha) to send code to Clarisse command port (like maya): https://marketplace.visualstudio.com/it ... comandport
For small script I prefer Clarisse because you don't really need the features of an IDE but when I have to do big script, VSCode is perfect.
Benoit VALDES
Isotropix
Clarisse QA
User avatar
bvaldes
 
Posts: 384
Joined: Mon Sep 26, 2016 10:44 am

Re: Help with python imports needed :)

Unread postby atnreg » Fri May 10, 2019 7:50 pm

bvaldes wrote:Hi,

That was a hidden feature and we release it with 4.0 I guess. For Clarisse I use VSCode and Script editor.
For vscode I've done a plugin (I am not a js dev so I've found a way to launch python code from JS ahahaha) to send code to Clarisse command port (like maya): https://marketplace.visualstudio.com/it ... comandport
For small script I prefer Clarisse because you don't really need the features of an IDE but when I have to do big script, VSCode is perfect.


WOW! This sounds VERY interesting, though I don't know yet what exactly I can do with it :mrgreen: but first the problem is that it does not work :O

I have done exactly as instructed:
-install the plugin to VSCode and enable it
-setup the port and host (used defaults as they were ok)
-enable the command port in Clarisse (with same default port)

To test it, I made simple script that just prints "yeah" :D
Then I have focus in that code and press Shift+Alt+S

In VSCode window, bottom right I get this message:
"command 'extension.sendToClarisse' not found" :shock:

I checked the keyboard shortcuts and it IS there and bound to Shift+Alt+S :o

Any ideas? :)

When I get it to work, I will probably figure out what exactly it can do but of course you can give some hints on use with the fix ideas :mrgreen:

Thank you very much!

Antti
Antti
AMD Ryzen Threadripper 2990wx (32c/64t),64GB RAM,NVIDIA GTX 1080ti,Win10
Clarisse 4.0SP1(2,2b crash with optix),Blender,Fusion360,Houdini,ZBrush,Onyx,SubstPnt...
Started: Clarisse 2016/10 (Py 2017/01), Python 2016/11
No business, just fun :)
atnreg
 
Posts: 482
Joined: Mon Sep 19, 2016 4:20 pm
Location: Helsinki, Finland

Re: Help with python imports needed :)

Unread postby atnreg » Fri May 10, 2019 8:00 pm

Here is another challenge for you to solve in addition to the extension :)

bvaldes wrote:

python code

import ix_helper
ix = ix_helper.ix



I just noticed that this breaks scriptedclasses, with that there is no ix.api.ModuleScriptedClassEngine() :o

Any ideas how to get it to work with those as well? :)
With the above code VSCode behaves nicely but the code would be nice to work inside Clarisse as well :mrgreen:

Thanks!

Antti
Antti
AMD Ryzen Threadripper 2990wx (32c/64t),64GB RAM,NVIDIA GTX 1080ti,Win10
Clarisse 4.0SP1(2,2b crash with optix),Blender,Fusion360,Houdini,ZBrush,Onyx,SubstPnt...
Started: Clarisse 2016/10 (Py 2017/01), Python 2016/11
No business, just fun :)
atnreg
 
Posts: 482
Joined: Mon Sep 19, 2016 4:20 pm
Location: Helsinki, Finland

Next

Return to Scripting