FranAJA Posted October 16, 2023 Share Posted October 16, 2023 Before banging my head against a wall unnecessarily, I'd like to understand the feasibility of such a Python script: 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. Quote Link to comment
Pat Stanford Posted October 16, 2023 Share Posted October 16, 2023 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. Quote Link to comment
michaelk Posted October 17, 2023 Share Posted October 17, 2023 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 Quote Link to comment
FranAJA Posted October 17, 2023 Author Share Posted October 17, 2023 Thank you both, i'll try to write some line of code this evening after work and come back soon. I need this as part of a bigger script to automate a redundant task we do in our office. Ps: Michaelk I was not able to open your file, this is what it shows: Quote Link to comment
michaelk Posted October 17, 2023 Share Posted October 17, 2023 It was a 2024 file. What version are you using? Quote Link to comment
FranAJA Posted October 17, 2023 Author Share Posted October 17, 2023 oh ok, i am 2023, but I have also the 2024 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.