Jump to content

trying to do a PIO which connects other PIOs.


Recommended Posts

Before banging my head against a wall unnecessarily, I'd like to understand the feasibility of such a Python script:

 

image.png.5682718542cb771c8530340d801c56ad.png

 

I have a starting point 1: PIOsquare (with a symbol), and other points 2, 3, 4 (PIOtriangle with a symbol).

 

The red polyline is a PIOpoly that starts from 1 and connects to 2, 3, and 4. The order of selecting 1, 2, 3, 4 should be chosen by the user.

 

  • There can be multiple PIOTriangles, and their number cannot be defined.
  • If I move a PIOTriangle and update the PIOpoly, the polyline should reattach to the moved PIOTriangle.

 

There are two methods I'm investigating:

 

Method a)

When the PIOpoly tool is clicked from the toolset, it should be possible to select the PIOsquare, and then the PIOtriangle. Find the insertion points of these PIOs and connect them with a polyline following the selection order. I have no idea what script to write or what commands to use, but somehow, I'll manage (if it's considered feasible by you).

 

Method b)

Each of these PIOs has a name. I create a dialog with two listboxes where you can select:

In the first, the PIOsquare

In the second, a list of PIOtriangles and maybe associate them with a progressive number, so the line will follow this order to connect.

 

Method c)
Please could you help me to identify this method if a and b are impossible to achieve,
 

I don't know if these two methods are feasible, which is why I would like to ask for your help before attempting something impossible.

 

Link to comment

Do you want the poly to change and follow the boxes when you drag the boxes around?

 

If so you want to use something like ForEachObjectAtPoint or PickObject to let the user click on the object in the order they want.  Store the UUID of the object (GetUUID) and the X/Y coordinates.  Then draw your polygon between those points.

 

Then when the Polygon PIO resets, it will need to look up the objects by UUID (GetObjectByUUID) and the X/Y coordinates and then redraw with the new values.

 

If you want to get fancy, you may be able to add an association between the objects, but you may have to make your PIIO Event Enabled to be able to do that. I know you can set an association to delete or reset an object when an associated object is deleted. I am not certain if you can force a reset on a move.  The documentation on AddAssociation on the developer site is better then in the HTML downloaded version of the Function Reference.

Link to comment

I think this is possible.

 

If the objects had two versions or modes:  A square and a triangle.  Make the square in charge of drawing the polygon.  Make the triangles update the square when they update.  Make the square update all the triangles when it updates. 

 

I have a trivial tool that does something sort of similar, in that each instance of the parametric object can update the others that it is related to.

 

The code isn't in python, but if you think it would be helpful I'll dig it up 🙂 

simple example.vwx

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