Jump to content

tbexon

Member
  • Content Count

    43
  • Joined

  • Last visited

Community Reputation

7 Neutral

About tbexon

  • Rank
    Greenhorn

Personal Information

  • Location
    United Kingdom

Recent Profile Visitors

450 profile views
  1. 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)
  2. Thanks Yasen, that makes sense. Quick follow up question, is there a way (via Vectorscript) to add parameters to the Lighting Device Parameter worksheet?
  3. 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.
  4. 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 )
  5. 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!
  6. 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?
  7. 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?
  8. 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!
  9. 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.
  10. 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.
  11. 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
  12. 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!
  13. So from my understanding the when you install the ZIP file it copies all the contents of the Zip FIle into the Users Plug in folder, so could you not package the Rource file within the .Zip then use vs.GetFolderPath() to get the users plug in folder, aswell as Library Folder and use shutil.move to move them from plugins folder to required folder. import shutil import os import vs def manualPackageInstall(foldername): shutil.move(os.path.join(vs.GetFolderPath(-2) , foldername ), # Path to Folder to move in plugin Folder os.path.join(vs.GetFolderPath(-13) , foldername)) # Path to Libraries in User Folder Something like that?
  14. I know this has been discussed in several threads before, but after extensive reading and experimenting I'm still clearly missing something. I'm trying to get the handle for a user selected object within an event enabled Plug in Tool. e.g User clicks button in OIP -> Highlight mode is turned on and user clicks on desired object -> Handle is returned and code continues onwards. I've created the event enabled object, and added the button to the OIP fine, and used TrackObjectN() to allow highlighting of only relevant objects. The issue I'm running into is actually getting the handle of the object. I understand that TrackObjectN is only highlighting, and not a selection mode, but from my reading of the wiki for TrackObjectN: def vs.TrackObjectN(traverseType, callback): return (outObj, p) It should return the handle and Co Ords whenever the user mouses over or clicks an object that relates to the criteria. e.g if the last action is a click on the desired object it should return that handle, or atleast it's co ordinates from which I could then use PickObject to get the handle. In reality when I try: outObj , p = vs.TrackObjectN(0, trackObjCallback) It throws a TypeError 'NoneType' object is not iterable. Given that when I try: vs.TrackObjectN(0,trackObjCallback) It functions as expected, but without returning any handle or co ordinates i'm guessing either i'm using this wrong or it doesn't actually return such information. I'm wondering if I need to try using vstGetEventInfo to look for a mouse button click and then capture the mouse's current Co Ordinates, however after searching "MiniCadHookIntf.h" I couldn't obviously see any obvious constant for a mouse click. TL/DR I'm trying to capture a handle for a user selected object, within a event enabled object and have clearly missed a step somewhere! Any help or nudges in the right direction would be greatly appreciated! Relevant parts of current code pasted below: import vs def makeOIP(): link_pos_button_id = 1234 # User Button Id theEvent, theEventData = vs.vsoGetEventInfo() # Gets Object Event info if theEvent == tb.Constants.kObjOnInitXProperties: # If the event is the initialisation of the object ok = vs.SetObjPropVS(tb.Constants.kObjXPropPreference, True) # Allows for creation of custom OIP?????? ok = vs.SetObjPropVS(tb.Constants.kObjXPropHasUIOverride, True) # Custom OIP Overrides standard UI vs.vsoInsertAllParams() # Inserts all Parameters into OIP displayString = "Link to HP" # text for button result = vs.vsoAppendWidget(tb.Constants.kWidgetButton,link_pos_button_id,displayString,doesNothing()) # Add Button to OIP if theEvent == tb.Constants.kObjOnObjectUIButtonHit: # If the event is a button being pressed if theEventData == link_pos_button_id: link_to_hp() # Function to run to allow user to select object. if theEvent == tb.Constants.kResetEventID: # If Object is reset # Code to run on object reset def doesNothing(): pass def trackObjCallback(h,x,y): HPHandle = vs.PickObject((x,y)) if vs.GetTypeN(h) == 86: return True def link_to_hp(): vs.TrackObjectN(0, trackObjCallback) outAction, outMessage1, outMessage2 = vs.vstGetEventInfo() #vs.Message(str(outObj)) makeOIP()

 

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...