Jump to content

AFDesign

Member
  • Content Count

    77
  • Joined

  • Last visited

Community Reputation

0 Neutral

2 Followers

About AFDesign

  • Rank
    Apprentice

Personal Information

  • Occupation
    Architect
  • Homepage
    www.andreafacchinello.it
  • Location
    Italy

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Yes, as I said previously, if you simply "replace" a string there is no problem, SetVSVar works correctly, and the white space isn't a problem if I use Dynarray of Char. The problem is that after encrypting the plugin, SetVSVar returns an empty value, as you can test in my last example (without using any other python code).
  2. I discovered why my plugin freeze: after encrypting the plugin and rebooting vectorworks, SetVSVar returns an empty variable. You can see the problem by creating a new plugin with this simple code: procedure testsetvsvar; VAR result:STRING; begin PythonBeginContext; PythonExecute('import vs'); PythonExecute('vs.SetVSVar("result","PYTHON TEXT")'); PythonEndContext; alertinform(concat('text from python : ',result),'',false); end; run(testsetvsvar); Without encryption, the plugin works correctly. If you encrypt the plugin and reboot Vectorworks, text from python result is empty.
  3. Sure! Same code, but string is directly assigned in python: PROCEDURE Example; VAR strName : String; BEGIN PythonBeginContext; PythonExecute('import vs'); PythonExecute('import hashlib'); PythonExecute('thestring="test"'); PythonExecute('myhash=hashlib.md5(thestring.encode())'); PythonExecute('vs.SetVSVar("strName", myhash.hexdigest())'); PythonEndContext; AlrtDialog( Concat( '*', strName, '*' ) ); END; RUN(Example); SetVSVar return the white space, after encoding the hash. I think I will not use this phyton code because it works only if the plugin is not encrypted. After encryption, the plugin freeze Vectorworks. If I remove the code and encrypt the plugin, it works. Maybe plugin encryption cause some problems to python code, I will try to understand why.
  4. It's true, if you simply "replace" a string there is no problem. But if you process the variable as in my example, the result has a white space, that disappear if you use "Dynarray of Char" instead of "string". Your example with hash process and String variable (white space in the result): PROCEDURE Example; VAR strName : String; BEGIN strName := ''; PythonBeginContext; PythonExecute('import vs'); PythonExecute('import hashlib'); PythonExecute('thestring=vs.GetVSVar(''strName'')'); PythonExecute('myhash=hashlib.md5(thestring.encode())'); PythonExecute('vs.SetVSVar("strName", myhash.hexdigest())'); PythonEndContext; AlrtDialog( Concat( '*', strName, '*' ) ); END; RUN(Example); Same example using Dynarray variable (correct result): PROCEDURE Example; VAR strName : Dynarray of Char; BEGIN strName := ''; PythonBeginContext; PythonExecute('import vs'); PythonExecute('import hashlib'); PythonExecute('thestring=vs.GetVSVar(''strName'')'); PythonExecute('myhash=hashlib.md5(thestring.encode())'); PythonExecute('vs.SetVSVar("strName", myhash.hexdigest())'); PythonEndContext; AlrtDialog( Concat( '*', strName, '*' ) ); END; RUN(Example); Maybe is something linked to string encoding in python.
  5. Yes, if you use SetVSVar with a STRING variable, the result has a white space at the beginning.
  6. Thank you Pat, I understood the problem: I passed the result to "var myMD5string:STRING;" variable, using STRING a white space is added. If I change to "var myMD5string:DYNARRAY OF CHAR" it works correctly. Thank you for your patience
  7. Using "mystring:DYNARRAY[] OF CHAR;" the hash is generated correctly, but now the result start with a white space. There is the same kind of bug to report.. Thank you procedure MD5test; var myMD5string:STRING; mystring:DYNARRAY[] OF CHAR; begin mystring:='test'; PythonBeginContext; PythonExecute('import vs'); PythonExecute('import hashlib'); PythonExecute('thestring=vs.GetVSVar(''mystring'')'); PythonExecute('vs.AlrtDialog("Imported in python <"+thestring+">")'); PythonExecute('myhash=hashlib.md5(thestring.encode())'); PythonExecute('vs.SetVSVar("myMD5string",myhash.hexdigest())'); PythonEndContext; alertinform(concat('<',myMD5string,'>'),'',false); {result start with a white space} end; run(MD5test);
  8. Thank you Patrick, my fear was only me seeing this error. I will use the workaround. kind regards Andrea
  9. Hi, this is the first time I try to use Python code inside Vectorscript, and I can't understand why by "importing" a variable in Python (using GetVSVar) the first character is automatically deleted. I'm trying to retrieve an MD5 hash from a string: procedure MD5test; var mystring,myMD5string:STRING; begin {importing the correct string} mystring:='test'; PythonBeginContext; PythonExecute('import vs'); PythonExecute('import hashlib'); PythonExecute('thestring=vs.GetVSVar(''mystring'')'); PythonExecute('vs.AlrtDialog("Imported in python <"+thestring+">")'); {string lose the first character!!} PythonExecute('myhash=hashlib.md5(thestring.encode())'); PythonExecute('vs.SetVSVar("myMD5string",myhash.hexdigest())'); PythonEndContext; alertinform(concat('input string: <',mystring,'> wrong result (result for "est"): ',myMD5string),'',false); {importing the string with a starting space} mystring:=' test'; PythonBeginContext; PythonExecute('import vs'); PythonExecute('import hashlib'); PythonExecute('thestring=vs.GetVSVar(''mystring'')'); PythonExecute('vs.AlrtDialog("Imported in python <"+thestring+">")'); PythonExecute('myhash=hashlib.md5(thestring.encode())'); PythonExecute('vs.SetVSVar("myMD5string",myhash.hexdigest())'); PythonEndContext; alertinform(concat('input string with starting space: <',mystring,'> correct result: ',myMD5string),'',false); {using the string directly} PythonBeginContext; PythonExecute('import vs'); PythonExecute('import hashlib'); PythonExecute('myhash=hashlib.md5(b"test")'); PythonExecute('vs.SetVSVar("myMD5string",myhash.hexdigest())'); PythonEndContext; alertinform(concat('correct result using "test" string directly in python: ',myMD5string),'',false); end; run(MD5test); I tried with Vectorworks 2020 and 2021, same problem. Maybe I'm doing something wrong? Thanks!
  10. GetPlanarRef doesn't work too. I created a new 2d path plugin and GetObjectVariableBoolean 650 and 651 works correctly, Pat! I will check what's wrong in my code. EDIT: Now I understood. Variable 650/651 read if an object is 2D or 3D: a 2D object in a custom plane is detected as 3D. For this reason the new plugin I created works, because I only created a 2D polyline to test. But my plugin use the 2D path to create a 3D object, so I receive the same value because my object is a 3D object, in both screen or plan mode. The only way to solve my problem is being able to read the custom plane tilt, but I didn't find a command for this. (I found GetWorkingPlaneN but it isn't relative to an object) Thank you all!
  11. Sorry I'm using a 2D path plugin so I can't post a small sample. I will create a new 2d path plugin and I will try your advice on it! I will let you know if it works tomorrow. Thank you!
  12. Thank you Pat, I tried but I always receive the same result, using 650 and 651. Maybe it is possible to detect if the plane is horizontal or tilted?
  13. Hi, I'm working with a 2D path object plugin, and I'd like to detect if the path has been created on a screen plane or layer plane. I tried this: GetObjectVariableBoolean(handle, 1160); using both plugin and path handles, but I always get the same result drawing in screen plane or layer plane. Any advice is appreciated, thanks! Andrea
  14. A new version of Foliage plugin is available: video Foliage 2.0 allows you to create a range of fairly complex hedges, espalier, topiary, mass and vertical plantings or areas with any symbol following a site model. More information on www.andreafacchinello.it.

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×
×
  • Create New...