twk Posted September 12, 2018 Share Posted September 12, 2018 As the title suggests, is this possible? If so, what is the syntax? 1 Quote Link to comment
Nicolas Goutte Posted September 12, 2018 Share Posted September 12, 2018 I suppose that it is possible, however "import" uses the current sys.path which might not what you want The possibilities I see are: - modify sys.path to have the path you need - use one of the functions of https://docs.python.org/3.5/library/runpy.html (if it suits you) - use one of the functions of https://docs.python.org/3.5/library/importlib.html As I have never used any of them from the Python provided with VW, I am not sure what the best solution might be. Quote Link to comment
twk Posted September 21, 2018 Author Share Posted September 21, 2018 Sorry for the late reply. Currently not possible with my tests Quote Link to comment
Nicolas Goutte Posted September 21, 2018 Share Posted September 21, 2018 It works for me, if I do something like: sys.path.append(r"c:\the\path\of\the\folder\where\my\module\is") import mymodule mymodule.dosomething() Quote Link to comment
twk Posted September 21, 2018 Author Share Posted September 21, 2018 No I meant, I'm trying to import a module from a script inside the VWX file. Quote Link to comment
Nicolas Goutte Posted September 21, 2018 Share Posted September 21, 2018 Ah, OK, then I have misunderstood you. Unfortunately I have no idea how to do what you would like to do. Quote Link to comment
erminio Posted January 17, 2020 Share Posted January 17, 2020 I had the same problem You have to add the path file into the "Script Options..." dialog Is that what you meant twk? Quote Link to comment
twk Posted January 18, 2020 Author Share Posted January 18, 2020 I was wanting to call a function from another script that is within the document resources. Not on a file somewhere else on the computer. cheers 1 Quote Link to comment
erminio Posted January 18, 2020 Share Posted January 18, 2020 Ok No idea about that In effect should be interesting Quote Link to comment
Pat Stanford Posted January 18, 2020 Share Posted January 18, 2020 In Vectorscript the following will get you a handle to a script object in the current file. I have not figured out how to get the text out of the object to be able to run it. I don't think there is a way to run Vectorscript, but PythonExecute should work IF you can find a way to get the text out of the handle to the object. Procedure Test; Var NumItems, ListID:LongInt; H1:Handle; S1:DynArray of Char; Begin ListId:=BuildResourceList2(49,0,'',NumItems,False); AlrtDialog(Concat(ListID,' - ',NumItems)); H1:=GetResourceFromList(ListID,1); AlrtDialog(GetName(H1)); End; Run(Test); Procedure Test; Var NumItems, ListID:LongInt; H1:Handle; S1:DynArray of Char; Begin ListId:=BuildResourceList2(49,0,'',NumItems,False); AlrtDialog(Concat(ListID,' - ',NumItems)); H1:=GetResourceFromList(ListID,1); AlrtDialog(GetName(H1)); End; Run(Test); 2 Quote Link to comment
Gregi Posted November 5, 2020 Share Posted November 5, 2020 I would like to do the same. I'm testing the function vs.GetScriptResource('Nameofmyscript)[1]. If I run a Script like this: text = str(vs.GetScriptResource('Ebenenauswahl')[1]) vs.CreateText(text) I get all the text of my script. But if I want to use a name out of 'Ebenenauswahl' it says "name '...' is not defined. What am I missing? Quote Link to comment
Gregi Posted November 9, 2020 Share Posted November 9, 2020 It works great with this code: vs.PythonExecute(str(vs.GetScriptResource('NameOfYourScriptInThisDocument')[1])) 1 1 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.