beanus Posted March 9, 2017 Share Posted March 9, 2017 is it possible to get marionette to pick two previously drawn points by selecting them with the mouse, then return the distance between the points Quote Link to comment
Patrick Winkler Posted March 9, 2017 Share Posted March 9, 2017 The problem is that you have to start the network by a click. That will unselect your points. You could do it with a classical script. Quote Link to comment
Patrick Winkler Posted March 9, 2017 Share Posted March 9, 2017 (edited) Maybe that network works for you. It measure the distance between 2 points in the class 'GetDist'. get_point_dist.vwx Edited March 9, 2017 by Patrick Winkler Quote Link to comment
Pat Stanford Posted March 9, 2017 Share Posted March 9, 2017 What are you going to do with the data? Do you just need to know what the distance is (One time display?) or need to place that distance in the drawing somehow? If you just want a "dialog box" to come up and show you the distance then a script will be a better and easier option. In my opinion, Marionette is the best option for programmatically creating objects in a drawing. Traditional scripts are a better option in most cases for modifying objects that already exist. Examples would be changing classes, fonts, colors, turning on options (Like Multiple Labels in Space objects) and even changing text blocks (company name changes) The following script will display a dialog box showing the distance between the first two selected locus points in a file. It does not check that the selected points are loci and will error if run with other type objects selected. If you need a more robust version it would not take much to check the object types and fail gracefully. Procedure LocLocDistance; Var H1,H2:Handle; X1,Y1,X2,Y2,Dist:Real; Begin H1:=FSActLayer; H2:=NextSObj(H1); GetLocPt(H1,X1,Y1); GetLocPt(H2,X2,Y2); Dist:=Distance(X1,Y1,X2,Y2); AlrtDialog(Concat('Distance is: ',Dist)); End; Run(LocLocDistance); Quote Link to comment
AlanW Posted March 9, 2017 Share Posted March 9, 2017 @Patrick WinklerHi, where did you get the criteria [C='GetDist']from?? couldn't see it in the VW developoer???Thanks Quote Link to comment
Pat Stanford Posted March 9, 2017 Share Posted March 9, 2017 C='GetDist' is objects that are in the class named 'GetDist' C= Class Name L= Layer Name Quote Link to comment
beanus Posted March 10, 2017 Author Share Posted March 10, 2017 20 hours ago, Pat Stanford said: What are you going to do with the data? Do you just need to know what the distance is (One time display?) or need to place that distance in the drawing somehow? If you just want a "dialog box" to come up and show you the distance then a script will be a better and easier option. In my opinion, Marionette is the best option for programmatically creating objects in a drawing. Traditional scripts are a better option in most cases for modifying objects that already exist. Examples would be changing classes, fonts, colors, turning on options (Like Multiple Labels in Space objects) and even changing text blocks (company name changes) The following script will display a dialog box showing the distance between the first two selected locus points in a file. It does not check that the selected points are loci and will error if run with other type objects selected. If you need a more robust version it would not take much to check the object types and fail gracefully. Procedure LocLocDistance; Var H1,H2:Handle; X1,Y1,X2,Y2,Dist:Real; Begin H1:=FSActLayer; H2:=NextSObj(H1); GetLocPt(H1,X1,Y1); GetLocPt(H2,X2,Y2); Dist:=Distance(X1,Y1,X2,Y2); AlrtDialog(Concat('Distance is: ',Dist)); End; Run(LocLocDistance); Quote Link to comment
beanus Posted March 10, 2017 Author Share Posted March 10, 2017 Hi Pat, I'm trying to create a tool which measures between two existing points on a drawing and then draws a simple 2d door or window. I quite often have to trace over old drawings usually in btmp format. In an old cad package I used in the past (Truecad) I managed write a simple piece of code that would enable me to click on two points and a simple 2d door or window would be drawn between the two points, I think the programing language was basic. Quote Link to comment
Pat Stanford Posted March 10, 2017 Share Posted March 10, 2017 What do you want the door and window to look like? There are Vectorscript commands that will let you interactively click on two points (even with a rubber banding preview). That will get the points. Then we just need to figure out how best to draw the stuff between. Could be Marionette. Could be just a group created via the script. Do these doors/windows need to be able to insert into VW Wall objects? Quote Link to comment
beanus Posted March 15, 2017 Author Share Posted March 15, 2017 Hi Pat, I only need a simple 2D door or window inserted between the points I select, it doesn't need to be inserted into wall objects. I've attached pdf of the sort of thing. 2D door & window.pdf Quote Link to comment
Pat Stanford Posted March 17, 2017 Share Posted March 17, 2017 This should give you at least a starting point. I have written 2 PlugIn Objects (PIOs). For this purpose PIOs are nice because they easily handle the user interface of getting the length you want the object to be and setting up the OIP (and the Tool Parameters) to allow you to set the Jam, Sash and Leaf depths and widths. It also makes the math very easy as internal to the PIO, everything is done in local, unrotated coordinates. VW then handles the translation to real world coordinates. Put the attached VSO files into your user folder/Plug-ins. In my case on the Mac, this is in User/My User Name/Library/Application Support/Vectorworks/2017/Plug-ins Once the files are in the right place, I think you have to resort VW for it to notice them, then you need to edit your workspace to add the new tools to a tool pallet. The tools should be in the Miscellaneous category. Once the tools are in your workspace, just select the tool and draw a line. The first time you run the tool the Parameters dialog box will open and you can set the defaults. You can change them later by clicking the Setting button (crossed wrench and pencil in the Mode bar). After closing the dialog box, just draw a line and after clicking on the second point it will be replaced by a door or window. The object is drawn with the Jams centered on and contained by the drawn line. If you would rather draw on the edges or have the Jams drawn outside the PIO line, changing the coordinates in the PIO scripts is relatively easy. Similarly, all the objects are drawn using a fill of NONE and the currency active drawing attributes. If you think some of the objects need different colors or line weights, the script can be relatively easily changed to allow that. Let me know what you think. Simple Door 2D.vso Simple Window 2D.vso 1 Quote Link to comment
beanus Posted March 17, 2017 Author Share Posted March 17, 2017 wow thanks Pat that's exactly what I wanted, thanks again. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.