Jump to content
Developer Wiki and Function Reference Links ×

distance between points


beanus

Recommended Posts

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);

 

Link to comment
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);

 

 

Link to comment

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.

Link to comment

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?

Link to comment

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

  • Like 1
Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...