-
Posts
2,825 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Articles
Marionette
Store
Posts posted by Dieter @ DWorks
-
-
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.
-
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.
- 1
-
16 hours ago, ahedley said:
My apologies, I meant plug-in tools.
No prob.
-
11 hours ago, ahedley said:
Most of my experimentation has been developing plugin objects, I want to broaden to tool objects.
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.
-
3 hours ago, twk said:
This is using the vs.GetRField call and not the P<parmaname> method.
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!
-
@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....
- 1
-
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
-
11 hours ago, MaxStudio said:
That being said, I find it much easier to comprehend looking at small pieces of code rather than a monster.
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.
- 1
-
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).
- 4
-
17 hours ago, ahedley said:
Thanks Dieter for the suggestion.
pt is still trapped in the callback function.
user_point = None creates the locus at 0,0 even before you have an oppportunity to select your user point.
Even if you make user_point a global variable within the callback function which should theoretically change user_point = None it still does not work.
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.
-
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
-
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.
-
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()
- 1
-
6 hours ago, JimW said:
*Cough* IliketheWindowsimplementationbetteranyway*Cough*
You can even do Quarters on Windows if you like. Though it's possible some common Linux distros had that first...
Yup, I use those quarters from time to time, really handy! Those shortkeys are one of the few I do out of my head
-
Someone has been looking at Windows..... It's exactly the same.
-
8 hours ago, twk said:
@Dieter @ DWorksgreat share!.. I may have opened my mouth too soon about contributing, seeing the VW2017 has just been released, our office is gearing up for the release here in NZ, and I'll be setting up the new templates etc.
What I had wanted to share though were mainly methods I had done for the Polygon methods, and some attributes that I've setup in our own library that could be used in the DLibrary opensource (attributes were open/closed,clockwise,vertexXY,vertexType etc.
I tried pulling a fork using PyCharm but I'm having trouble setting up the bitbucket plugin for PyCharm. Will try again and post back.
Just share when you're ready.
You don't need any plugin for PyCharm, version control is already baked in: https://www.jetbrains.com/help/pycharm/2016.1/version-control-with-pycharm.html.
Just check out the project, open it in PyCharm, and it should detect all, probably asking you what to do. Then you can just use the version control menu from then on. -
@twk, I released an initial 2017 version, with an improved plugin setup, like you can see in the example: https://bitbucket.org/dieterdworks/vw-dlibrary/wiki/2017/examples/plugin_setup.py.
- 1
-
yes, and so many others, level bounding for symbols, etc.... I was really surprised to see all these things they didn't mention, VW is on a good path again. Isn't there a list with ALL improvements and new things?
I really hope for a continuous release of new features to know these improvements instead of one big one each year. (or one big one for the BIG sales stuff, and updates for all those smaller things)
-
I have the Surface Pro 4 i7 16GB RAM 256 GB SSD, and I've tested VW2016 on it. It works great, though some renderings didn't work. I guess for all work, except rendering, this machine will do. The main reason I bought this, is because I wanted to use VW on the go and to show VW stuff to clients, and I was totally happy with my first Pro model. The pen is amazing! I would not recommend any such device as the main VW machine though. Still prefer to assemble my own setup for that.
- 1
-
On 9/15/2016 at 2:01 AM, twk said:
Hi Dieter, are you still planning on an opensource-type library? As I would like to start contributing for the next vw2017 release. I feel a bit more comfortable now with Git and OOP.
cheers
DLibrary is already opensource and anyone can contribute. Some parts can really be improved a lot. For the new VW2017 release, I have rewritten the Vectorworks module, so plugins can be more easily created with it, by using configuration. I'll also add examples etc... When contributing, just keep in mind that in one main version, no breaking changes are allowed, and between versions, try to keep them to a minimum.
So please do contribute on anything that's needed. And ask away if something isn't clear so we can improve the docs etc...
-
@twk, most of the time when I encounter such bug, I just do a normal bug submit, after confirming on the scripting list that it's really a bug.
-
On 06/09/2016 at 7:15 PM, zoomer said:
I second the signature move to the top.
Currently it is quite hard for me to recognize where the content of a post is,
where one post begins/ends and where the next post starts.So true, as this new layout may seem nice and modern at first, it's really terrible. The design is really bad, because you can't see the contexts well enough, which makes it hard to navigate and use the site. Also more color would be nice, maybe add some variable in the styling to change that color every year to reflect the new VW color?
-
As it's VW that sets these values for you, it's a bug in VW, and you will not be able to do something about it.
-
value = getattr(vs, 'P%s' % name)
or shorter: vs.PYourParameterName
[code]
DLibrary - a Python library to create plugins faster and with more ease!
in Python Scripting
Posted
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.