Jump to content

tbexon

Member
  • Posts

    45
  • Joined

  • Last visited

Reputation

7 Neutral

Personal Information

  • Homepage
    https://www.tb-lx.com/prod-lx-plugins/
  • Location
    United Kingdom

Recent Profile Visitors

556 profile views
  1. Thanks Josh, When you say the Data Folder do you mean /Plug-ins/Data or /Plug-ins/Common/Data? Given that vs.GetFolderPath() has an attribute for Common/Data but not /Data I should probably use the Common folder?
  2. So I was doing some bug hunting within one of my plug ins, and I seem to be getting some unexpected results from the vs.FindFileInPluginFolder() function. I'm using the function to retrieve the filepath for a file within my plug ins folder, which works absolutely fine. Where I'm running into problems is when I'm trying to handle a situation where said file does NOT exist... Below is the test code i'm using: import vs ok,path = vs.FindFileInPluginFolder('FileName.ini') if ok: # If File Exists vs.AlrtDialog("ok") else: # If File Does NOT Exist vs.AlrtDialog("no") The problem I seem to be running into is that the ok Boolean keeps returning True even when the file is definitely not present within the Plug Ins folder. First I thought it was still just cached in VW memory somewhere, so tried the old restarting VW trick. Same result. Eventually I noticed that I had another File called "FileName.vso" in the plug ins folder. a bit of experimentation later yielded these results: When FileName.ini is NOT present within Plug Ins Folder, but FileName.vso IS present: FindFileInPluginFolder('FileName.ini') Returns True FindFileInPluginFolder('RandomName.ini') Returns False FindFileInPluginFolder('FileName.randomfileextension') Returns True So from this it would suggest to me that FindFilePluginFolder command ignores file extensions and just looks for the File Name. Is this working as intended? The Function reference does say it searches for File Name, but then the example further down has an extension attached to it, and I believe it's fairly common practice within most filename/path related programming functions to take the extension into account? If this is working as intended does anyone have a nice workaround for dealing with same file names but different extensions. I was thinking I could probably do something with vs.GetFolderPath(-2) and some os.path commands... I realize the simplest solution is just to make sure every file has a unique name, which is probably what i'll end up doing, but thought i'd see if anyone has any helpful insights before I go digging through all my code for every reference to this particular file...
  3. I thought as much, are you aware of any handy guide or helpful threads that may point me in the right direction? (I can't say i've delved too far into the SDK yet)
  4. Thanks Yasen, that makes sense. Quick follow up question, is there a way (via Vectorscript) to add parameters to the Lighting Device Parameter worksheet?
  5. I have not seen the notes, do you have a link to them? I had a search on developer.vectorworks.com for them but it doesn't seem to return any results? I think what i've discovered is that using Circles as my testing object, was a poor choice, from what I can gather FindObjAtPt_Create will only return a circle object if the radius intersects with perimeter of said object. Luckily with both PIOs and Rectangles (which are the two main object types i'm interested in right now) the function does return any part of the object that is within the radius.
  6. Thanks Josh I've been having a play with FindObjAtPt_Create, and I'm struggling to understand how the radius parameters works. I've drawn a circle with a radius of 20000mm, and placed a number of objects within it and outside (see below image), however the results I'm getting are not as expected. If I set the functions radius to 20000 it still picks up objects slightly out of that radius, for instance the object with the red circle around it gets picked up even though the distance from centre (which is the location i'm selecting each time for the starting co ordinates) is 22608. Strangely even though it's picking up objects further away than the overall Circle, it's not picking the containing circle itself... Also from what I can tell I need to set the radius large enough to encompass the entire object for it to be included in the list. I've adapted the code from the example on the wiki as below: import vs def PickPointCallback(pt): startContainer = vs.Handle(); list = vs.FindObjAtPt_Create(startContainer, 1, 0, pt[0], pt[1], 20000) cnt = vs.FindObjAtPt_GetCount(list) vs.AlrtDialog("Initial Co ords: "+str(pt[0])+ ' '+str(pt[1])) for i in range(cnt): hObj = vs.FindObjAtPt_GetObj( list, i ) x2,y2 = vs.HCenter(hObj) d = vs.Distance(pt[0], pt[1], x2, y2) vs.AlrtDialog( 'Index: ' + str(i) + ' Obj Type: ' + str(vs.GetTypeN(hObj)) + ' Dist: '+str(d) ) vs.FindObjAtPt_Delete( list ) vs.GetPt( PickPointCallback )
  7. Hi All Apologies if this has been covered somewhere else, though I'm struggling to find any similar topics, could just be i'm not using the right terminology. I'm trying to recreate the functionality similar to that of Spotlight Hanging Positions and their ability to automatically assign Positions to Fixtures that overlap with the HP. e.g: I want to have a "base" PIO and when I insert a different PIO (Say PIO 2) into the drawing, PIO 2 calculates if it overlaps with any "Base" PIO's and if so queries said "Base" object and retrieves some information from it. The bit I'm struggling with is how to go about working out what objects overlap with said PIO 2. I suppose I could get PIO 2's bounding box co ords and then somehow query if there are any other objects within those same Coordinates. But I though I'd ask if anyone has any better ideas before I go down this route? Thanks In advance!
  8. So I I go about this a slightly different way. I'm not saying it's the correct way, or that there aren't better ways, but it atleast works for me! To get a Lighting Device parameter I simply do a GetRField() command on the objects 'Lighting Device' Parametric Record (which as far as i'm aware is attached to all Spotlight Lighting Devices) I did a test comparing both methods, and got the same results as you with LDevice_GetParamStr not returning Inst Type, however querying the record via GetRField did return the correct results. I also confirmed that LDevice_GetParamStr does work on some fields (such as Position). (Apologies it's written in Python Script rather than Vectorscript, but the results should be the same!) import vs field = 'Inst Type' handle = vs.FSActLayer() param = vs.LDevice_GetParamStr(handle, 0, -1, field) vs.AlrtDialog("Param: {}".format(param)) val = vs.GetRField(handle, 'Lighting Device', field) vs.AlrtDialog("Rec Val: {}".format(str(val))) It is strange that LDevice_GetParamStr doesn't return certain field (and some fairly critical fields one could argue) could this be a potential bug? @JBenghiat or @K.Lalkovski Have you come across this at all?
  9. Ok cool so i can use vs.EvalStr(vs.Handle(0), 1=1) to get the localized string for True and then just compare that to the results from the records?
  10. So I have an event enabled PIO with a couple of Boolean parameters. Up until now I've been using the below to get the parameter's current state by converting the string to bool, as GetRField returns strings, which I thought was fine. show_weight_bool = strtobool(vs.GetRField(objectHand, objectName, "Show Weight")) HOWEVER An unexpected bug has come up, from someone who tried this plug in on a non english version of Vectorworks (it was German in this particular instance). The error thrown from the strtobool function, was: ValueError: invalid truth value 'wahr' From what I can gather, the GetRField seems to be returning the localized value for the checkbox (in this instance 'wahr' which I'm given to understand from a quick google means True), rather than, as I was hoping just a pythonic True, but in string form. Firstly is this working as intended? I presume so as it would make sense that if you were extracting the string you would want said string to be in the localized language rather than always in english... SO does anyone have any clever ways around this? I've been hunting through the Function Reference but nothing obvious has jumped out at me, I was hoping it might be as simple as there was a vs.GetRBool or something similar that returns a BOOLEAN value, but so far I can't find it (I'm certainly not saying it's not there, just that I have not been able to locate it!) I'm hoping there's a super obvious answer that I'm just missing here!
  11. val = vs.GetLBHeaderTextWidth('Some Text', False) vs.Message(val) I just tried this on win10 in VW 2021 SP2 (574483) 64 bit and it crashed my VW straight away.
  12. I'm running Windows @domC Following you're suggested process, I got the same results. Strangely when I look at the environment paths within the VW Python environment, using sys.path(), "Python Externals" is in there. I'm still having issues with my specific package (pyOpenSSL) DLL load failed while importing _openssl: The specified module could not be found. If I try running with a clean 3.8 interpreter outside of VW it runs fine, same as within 2020.
  13. There is a work around. Rather than writing the script within the Plug in script itself write it in a YourScriptName.py file located in the same directory as the .vsm file within you're plug in folder. Then, within the Plug In Script, you just need to import the other script: import YourScriptName The .py File is still easily read so the next step, when you're ready to encrypt and distribute said plugin, is to swap the .py for the compiled python file( .pyc), which is located within the "__pycache__" folder of whatever directory the .py file is stored in. (for more info on .pyc files check out this) As long as you put the .pyc in the exact same location as where the .py was, it should function exactly the same. This still isn't perfect. Compiled files can still be de compiled but this requires a much higher level of knowledge than simply opening in a text editor! For more general info on encrypting python plug ins check out this thread
  14. So I just moved all my plugins across to VW 2021, and I'm now getting Import Errors for Plug ins that use the External Package PyOpenSSL. The error i'm getting is: DLL load failed while importing _openssl: The specified module could not be found. I've tried both deleting and reinstalling PyOpenSSL via VerifyOrGetLib, aswell as simply copying the working "Python Externals" from 2020 Plug in folder, neither seems to solve the issue. Pip does seem to be successfully installing PyOpenSSL, with the most up to date versions of it's dependents. I'm aware that with 2021 the Python distribution has been upgraded to 3.8, so I'm wondering if something to do with that could be causing this? Checking the docs here it is compatible with 3.5+ I don't believe it's an issue with the package itself as if I install it, and run from my local copy of Python 3.8 via IDLE it imports fine. Any thoughts would be greatly appreciated! This is rather where my knowledge reaches it's limit!
×
×
  • Create New...