Jump to content

Dieter @ DWorks

  • Posts

  • Joined

  • Last visited


29 Great


Personal Information

  • Occupation
    UI/UX engineer & engineer in construction
  • Homepage
  • Hobbies
    VectorWorks, VectorScript, Programming...
  • Location
    Belgium - Gent

Recent Profile Visitors

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

  1. Hi, I don't maintain it anymore because of medical reasons, but VW doesn't change that fast, and thus it should still work. If there are things not working, it will be somewhere on the developer guide on how to upgrade for the newer version. It's open source, so everyone can contribute to the code.
  2. I tried Tkinter before, and it doesn't work with VW. You should avoid it and use the VW dialog stuff, so it's also consistent for the user.
  3. You can test without VW if you mock the vs module. It's easy and straightforward to do. Though how easy it is depends on what exactly you are testing.... As for testing your script from within VW, take a look at DLibrary, which did this.
  4. Tools aren't objects. Tools are used to generate objects. For example, the rectangle tool will let you create a rectangle in different ways. The rectangle object is the result. The creation of it is what the tool does, and those two have no connection at all. An object should not know how it is created.
  5. Aha, so that could be the real problem! So P.... is cutting it off, and thus it's better to use GetRField for text fields... Hmmm. Need to test this and then add it as improvement to DLibrary!
  6. @JBenghiat, I use SetRField for the plugin instance parameter, and if I put anything greater than 256, it's get truncated. (I use Python). So I guess the unlimited storage only counts for normal records....
  7. There should be no limit, but there still is though.... Don't know if it's because of the calls, or the actual data storage, but I have had the limit with a plugin I made this summer... It's still 256
  8. A monster? That was a minimal version. You'll have to think differently in Python then you did in VectorScript. Working OOP, you can split things up in very small pieces, and then let them work together. Every piece has it's own responsibility, and this makes your code more clear and better to read. You only have to read the main flow, and if you are interested in the details, you can look deeper. For example, if you look at the run in it, you can read was is going on, without needing to know the details, you know what will be drawn, not how. If you want to know how, you can look deeper.
  9. Hi, for those interested, DLibrary is an open-source Python library to create VW plugins. I have moved the repo to github (still have to transfer the issues), as it has better collaboration support and a far better wiki system. https://github.com/dietergeerts/dlibrary. The main benefits of the library is that you can program OOP, plugin setup is a breeze, so are custom dialogs. Not all is already in there, but everyone is welcome to contribute. Just wanted to post this so that more people know of it's existence, and that it's still alive (and kicking).
  10. I see now, it's stated in the docs that script execution will not be blocked (like most other functions do): http://developer.vectorworks.net/index.php/VS:GetPt That means that you have to make sure that you first call that function, and that the callback is actually your main function to execute with everything in it.
  11. You could use http://developer.vectorworks.net/index.php/VS:ValidAngStr, which converst a string into a float angle. The same goes for distances in python, you can't use string, but they can be converted. I put this into dlibrary, so we can use strings like '5m', have a look, you should do something similar for angles: https://bitbucket.org/dieterdworks/vw-dlibrary/src/ac2110e58529cb69cede4a04a94219fc38634fd0/dlibrary/document.py?at=master&fileviewer=file-view-default
  12. Why not store it in a var of the containing scope? user_point = None def catch_point(pt): user_point = pt vs.GetPt(catch_point) vs.Locus(user_point) vs.Message(user_point[0],' ',user_point[1]) vs.ReDraw() Please take a look at https://bitbucket.org/dieterdworks/vw-dlibrary, this would be an ideal thing to put in it.
  13. Some tips: - A file is a module, which is a unit with stuff that work together. You'll never split it up. Things that belong together in a module should stay together. - Never use global variables, there are always better ways. Functions should almost always stand on their own, unless it's a function inside a class that needs the 'state' of the class. - use good names for your vars, so it's clear what they are, if you revisit your code years later, you want to know how it works, good naming will help with that. - use oop, so that the code is more clear and each thing is self-contained. It will make your code better, readable, etc.... Here is a better version of your code (at the top of my head, did not test it, depending on what you are trying to achieve, this could be made far better, some imports are missing, i'm not using my standard IDE right now.) import vs class Shape(object, metaclass=ABCMeta): def __init__(self, origin: tuple, width: float, height: float): """ :type origin: (float, float) """ self.__origin = {x: origin[0], y: origin[1]} self.__width = width self.__height = height @property def origin(self) -> dict: return self.__origin @property def width(self) -> float: return self.__width @property def height(self) -> float: return self.__height @abstractmethod def draw(self): pass class Rectangle(Shape): def draw(self): vs.Rect(self.origin.x, self.origin.y, self.origin.x + self.width, self.origin.y + self.height) class Oval(Shape): def draw(self): vs.Oval(self.origin.x, self.origin.y, self.origin.x + self.width, self.origin.y + self.height) def run(): plugin_length = vs.PLineLength plugin_height = vs.PBoxWidth x = 0 y = 0 - plugin_height / 2 vs.PenSize(2) if plugin_length == 6: vs.AlrtDialog('Hello world.') return my_shape_class = Rectangle if plugin_length < 6 else Oval my_shape = my_shape_class((x, y), plugin_length, plugin_height) my_shape.draw() # This should not be needed here, you can call it in your plugin file itself. run()
  14. Yup, I use those quarters from time to time, really handy! Those shortkeys are one of the few I do out of my head
  • Create New...