michaelk Posted May 23, 2020 Share Posted May 23, 2020 This is a really basic question: I've noticed while debugging a rectangular parametric objet that the script runs 2 or 3 times then creates the object. Should I be stopping the 2nd and 3rd running of the script? Why is it doing this? In this example I have a solid subtraction that is failing. When run in the first mode (draw the center line first) it runs but doesn't subtract. When run in the second mode (1 edge first) it loops forever. Taking out the solid subtraction fixes the loop. Running the exact same code as a script works. The solid subtraction succeeds. Is there something about solid subtractions that isn't obvious? Can't get the integer result of the solid subtraction because the program hangs. Quote Link to comment
MullinRJ Posted May 23, 2020 Share Posted May 23, 2020 8 hours ago, michaelk said: Should I be stopping the 2nd and 3rd running of the script? Short answer - NO! Michael, Script Palette scripts and Plug-in scripts are handled completely differently. Scripts run from a Script Palette only run when you click on them, meaning once. Plug-in objects run when VW tells them to, which is in response to the selection state of the Plug-in and the events that VW "throws" at them. The only event where you are supposed to create geometry is inside event 3, the ResetObject event*. And by the way, your object can run way more than 3 times in a row under the right circumstances. Every action in your drawing has the potential of generating a series of events that a Plug-in object might handle (Placing a new PIO; Selecting; Duplicating; Moving; Rotating; Editing the OIP; Editing a Symbol that is in your PIO; Deleting; Cutting; Pasting; Moving a ControlPoint; .... I'm sure there are actions I missed, but do you get the idea?), and different PIO types have different event sequences. Point objects differ from Linear objects, which differ from Rectangle objects, which differ from Path objects, etc. In addition to handling events that VW generates, you can issue events of your own, like ResetObject again. You can also enable or filter events that your plugin "sees", or is aware of. This is done in event 5 (ObjOnInitXProperties). The combination of events and user actions is quite large. Be prepared to be stymied a lot in the beginning. Oh, you're already there. That's good, it means you're trying things. It also means you're human. I'd hate to think this was easy for you. 😉 No disrespect intended. You should probably start taking notes of what events you receive for the actions you are performing. It's the best way to get an overall picture of the way your code is setup and how it responds. Put an Alert Dialog at the front of your code and display every event that comes in. Write them down. Patterns will emerge and your questions will become more detailed. Welcome to the bottom of the rabbit hole. The real adventure is climbing out. Raymond * If you draw outside of event 3, your objects will NOT be part of the plugin and may "litter" your drawing. This may be your intention, so it can be done, but you must do it carefully. Quote Link to comment
michaelk Posted May 24, 2020 Author Share Posted May 24, 2020 11 hours ago, MullinRJ said: You should probably start taking notes of what events you receive for the actions you are performing. It's the best way to get an overall picture of the way your code is setup and how it responds. Put an Alert Dialog at the front of your code and display every event that comes in. Write them down. Patterns will emerge and your questions will become more detailed. Welcome to the bottom of the rabbit hole. The real adventure is climbing out. This sounds interesting! Not sure what that code looks like. GetEvent(?) vsoGetEventInfo(x,y)? Wow. That is not an overwhelming amount of documentation. 😁 Quote Link to comment
MullinRJ Posted May 24, 2020 Share Posted May 24, 2020 Michael, Place an AlrtDialog() command at the front of your Event Loop in your main program like this: BEGIN result := GetCustomObjectInfo(PIOName, PIOHand, recHand, wallHand); vsoGetEventInfo(theEvent, theButton); AlrtDialog(concat('Top of Event Loop: ', theEvent, ' ', theButton)); { usually commented - used for debug } case theEvent of ... end; { case } END; Run(MyPIO); Comment out the AlrtDialog() for normal running. This will show you exactly what PIO events you are receiving. Raymond 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.