Jump to content

tbexon

Member
  • Content Count

    32
  • Joined

  • Last visited

Community Reputation

6 Neutral

About tbexon

  • Rank
    Greenhorn

Personal Information

  • Location
    United Kingdom

Recent Profile Visitors

325 profile views
  1. 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
  2. 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!
  3. 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?
  4. 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()
  5. Have a look at this thread, i'm not sure how much experience with python you have, but basically VW comes with Python 3.5 packaged within the VW environment, you ~could~ download python 3.6 and manually replace it within the VW installation, HOWEVER I wouldn't recommend this, as you have no way of knowing how that may affect the stability and functionality of Vectorworks itself which, as I understand it, also utilizes said python installation. I believe python may be getting upgraded in an upcoming future release, however @Vlado is the man to answer that.
  6. Thanks @Andy Broomell I had looked through that folder, don't know how I missed that!
  7. Ok this one may be a bit of a morph of scripting and more general VW user question. I've made use of the predefined dialog vs.AlertInformDontShowAgain within one of my scripts, which works absolutely fine, however now that i've checked 'don't show again' to test that it did do as advertised I can't seem to find a way to get that alert to show again. Is there a settings dialog or file squirreled away somewhere with a list of all suppressed dialogs? Looking at the python example for the function is looks like the dialog is stored somewhere, but I can't for the life of me find any reference to where! def Example(): arrayText = ('DontShowDialogAgainCategory', 'DontShowDialogAgainItem', #{Should be unique for every AlertInformDontShowAgain} '') # python uses a tuple vs.AlertInformDontShowAgain('This is an invalid item.', '', False, arrayText); Example()
  8. Thanks! You're script worked as expected! @Pat Stanford You were correct that NextObj(Fin3D) does return the Symbol for the Hanging Position, or interestingly the CustomObjectProfileGroup should the HP be made of multiple pieces of Truss Objects, which is extremely handy! I thought I was going to have to calculate the individual dimensions for each truss object and add them together for those kind of HPs! It's a shame that my method didn't work, would have been quite a simple solution to what I was trying to achieve! Luckily thanks to you're help, I found a different method that works just aswell, just with a few more lines of code! Just for my own understanding does anyone know why the Co Ordinates don't update until after the script has run? I assume it's not so much that the geometry is not updating but instead whatever script Spotlight needs to run to recalculate the object after changing the record, doesn't run until the users script has finished?
  9. So I'm writing a script that requires the X and Y co ordinates for the Center of a Hanging Position, this I can get no problem using vs.HCenter() the problem i'm having is that if you have the position name turned on for that position, it takes that into account for the Center Co Ords (from what I understand this is because it's taking the center of the Bounding Box for the HP), meaning that the returned values aren't actually centered on the HP itself. My work around for this was to add in something that turns off the HP Name whilst the script is running. This works fine, however the problem i'm having is the Co-Ords are not updating after I have disabled the POS Name until AFTER the script has finished running. E.g: Co Ords with POS Name turned on = 300, 100 Co Ords after POS Name Disabled = 300, 100 Manually getting HP Co Ords AFTER script has Finished = 100, 100 I've tried adding in vs.ResetObject() and vs.ReDrawSelection() but to no avail. Code Below: import vs objectHandle = vs.FSActLayer() vs.SetRField(objectHandle, 'Light Position Obj', 'Position Summary', 'False') # Sets Show Position Name to False vs.ResetObject(objectHandle) vs.RedrawSelection() hpX, hpY = vs.HCenter(objectHandle) # Gets Center of HP symname = vs.GetRField(objectHandle,'Light Position Obj', "Symbol Name") # Gets the Symbol name from HP record symHandle = vs.GetObject(symname) # Gets the Symbol's handle from the POS name (p1X, p1Y), (p2X, p2Y) = vs.GetBBox(symHandle) # Gets co ords of Bounding Box vs.Message(str(p1X)+str(p1Y)+str(p2X)+str(p2Y)) vs.Rect(p1X,p1Y,p2X,p2Y) # Creates Rectangle from Sym Def Bounding Box @ 0,0 on document rectHandle = vs.LNewObj() # Gets Handle for newly Created Rectangle rectX, rectY = vs.HCenter(rectHandle) # Get Center of newly created Rectangle X = hpX - rectX # Calculate X Distance Y = hpY - rectY # Calculate Y Distance vs.Move3DObj(rectHandle,X,Y,0) # Moves Rect to HP Center Is there some other command I need to run to recalculate the objects Co Ordinates?
  10. Will this fix be applied to a future 2020 update? Or is it exclusive to 2021? I’m aware, especially in these troubling times, a lot of my potential users will still be using 2020 for the foreseeable future, and it would be good if I didn’t have to have a separate installation method for them.
  11. Thanks! Back to the drawing board I go!
  12. Hi All Apologies if I've missed something glaringly obvious (I've searched the forums and can't seem to find an answer) i'm wanting to create a dialog where the user can still interact with the OIP and the rest of VW whilst said dialog is open and running. Effectively I want a dialog window that is open and on top, but still allows users to interact with the rest of VW. I'm wondering if I might be able to accomplish this with SetLayoutOption() however for the life of me, I can't find a list of options and values I can pass to this command. Is there a convenient list of said options somewhere? Or can anyone suggest another way to accomplish this?
  13. @K.Lalkovski Apologies for the delay getting back to you, I've been away from my PC for a while! So I followed your instructions, and found that the new pip3 solved the issue, VerifyorGetLib appears to work once again. To confirm something else hadn't changed in the meantime I swapped back to the old version of pip3 and received the same expected errors as before. Is that a different version of pip from the once distributed within the VW installer? I know I tried completely uninstalling and reinstalling VW early on in my fault finding process!
  14. @K.Lalkovski I'm on SP4 Build 550627 - Which I notice is a different build to yourself, I THINK i'm on the most up to date version, as I tried reinstalling VW from a fresh download as part of my fault finding process. output from script: === RESTART: D:\Program Files\Vectorworks 2020\Python35\get encoding info.py === sys.stdin.encoding = utf-8 locale.getpreferredencoding = cp1252 locale.getpreferredencoding = cp1252 sys.getdefaultencoding = utf-8 sys.getfilesystemencoding = utf-8
  15. As a work around can anyone think of any reason why adding into the install.py script some code to manually copy what would normally be the final contents of external python packages into the user folder?

 

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