VvierA Posted December 9, 2015 Share Posted December 9, 2015 Hi everybody, another day, another challenge... I'd like to make a custom point object with the following feature: When I hover with the cursor over drawing elements they should highlight in the standard Vectorworks manner. By clicking on one of the highlighted elements the plugin should retrieve information of the element (for example the area of that element). Does anybody know, how to do this? If I make a new custom point object and start it, there is no highlighting while hovering over the drawing. And in the next step I wouldn't know how to get a handle to the element I clicked on. Thanks for help VvierA Quote Link to comment
Dieter @ DWorks Posted December 9, 2015 Share Posted December 9, 2015 (edited) Hi everybody, I'd like to make a custom point object with the following feature: When I hover with the cursor over drawing elements they should highlight in the standard Vectorworks manner. By clicking on one of the highlighted elements the plugin should retrieve information of the element (for example the area of that element). Does anybody know, how to do this? Do you mean that when you hover over the custom point object, or another object that's not your plugin? Or do you mean one of the objects in your plugin? What exactly do you need to do? I get the impression it's not an custom object you need. Edited December 9, 2015 by Dieter @ DWorks Quote Link to comment
Hippocode Posted December 9, 2015 Share Posted December 9, 2015 (edited) I'm not sure this is possible with VS. What you need to do is to overwrite the tool behavior, particularly the mouse move and click events. If there is no way of overwriting the tool, you might do it with a menu command instead or object event: http://developer.vectorworks.net/index.php/VS:vstGetPickObject You could trigger this by a button in the OIP. I do exactly what you describe for a custom tool myself, but it's made with the SDK so I have no idea how to do this in vectorscript. Edited December 9, 2015 by Hippocode Quote Link to comment
VvierA Posted December 10, 2015 Author Share Posted December 10, 2015 Do you mean that when you hover over the custom point object, or another object that's not your plugin? Or do you mean one of the objects in your plugin? What exactly do you need to do? I get the impression it's not an custom object you need. I'd like the following usage: - select the tool - hover over the drawing with the cursor - VW should highlight the graphic elements while I hover (could be everything - not necessarily a custom object) - I click one one of the graphic elements while it is highlighted - my plugin object retrieves information of that element and my object is placed right there where I clicked - the plugin object shows information of the element like a stamp (for example the area of the element) And yes: maybe it's more like a custom tool than a custom plugin object. Do you think, I can succeed by making a tool rather than a plugin object? I'm not sure this is possible with VS. What you need to do is to overwrite the tool behavior, particularly the mouse move and click events. If there is no way of overwriting the tool, you might do it with a menu command instead or object event: http://developer.vectorworks.net/index.php/VS:vstGetPickObject You could trigger this by a button in the OIP. Thank you, I will have a look at it. Maybe it works. Quote Link to comment
Hippocode Posted December 10, 2015 Share Posted December 10, 2015 After taking a quick look at the VS function reference, there is a section for "tool events". So it might be possible after all Note that you need to create the hovering part on your own. This is what I use for one of my tools in the SDK. It will highlight any object compared with an array of object names. void CMEPLabelToolDef_EventSink::MouseMove() { if(this->GetToolPointsCount() == 0) { MCObjectHandle OverObject; short OverPart; SintptrT Code; gSDK->TrackTool(OverObject, OverPart, Code); if(OverObject != NULL) { //if(OverObject != Object) { gSDK->EmptyToolHighlightingList(); if(VWParametricObj::IsParametricObject(OverObject)) { VWParametricObj Obj(OverObject); TXString ObjName = Obj.GetParametricName(); // Valid object ? if(std::find(fTaggableObjects.begin(),fTaggableObjects.end(),ObjName) != fTaggableObjects.end()) { HighLightedObject = OverObject; gSDK->AddToolHighlightingObject(HighLightedObject); } else if(std::find(fTaggableGroupObjects.begin(),fTaggableGroupObjects.end(),ObjName) != fTaggableGroupObjects.end()) { HighLightedObject = OverObject; gSDK->AddToolHighlightingObject(HighLightedObject); } } } } else { if(HighLightedObject != NULL) { gSDK->EmptyToolHighlightingList(); HighLightedObject = NULL; } } } //return VWToolDefault_EventSink::MouseMove(); } Quote Link to comment
Dieter @ DWorks Posted December 10, 2015 Share Posted December 10, 2015 Do you mean that when you hover over the custom point object, or another object that's not your plugin? Or do you mean one of the objects in your plugin? What exactly do you need to do? I get the impression it's not an custom object you need. I'd like the following usage: - select the tool - hover over the drawing with the cursor - VW should highlight the graphic elements while I hover (could be everything - not necessarily a custom object) - I click one one of the graphic elements while it is highlighted - my plugin object retrieves information of that element and my object is placed right there where I clicked - the plugin object shows information of the element like a stamp (for example the area of the element) And yes: maybe it's more like a custom tool than a custom plugin object. Do you think, I can succeed by making a tool rather than a plugin object? Yes, you will need both a custom tool and a custom object. The custom tool will let the user select the object where you want the info from, then create the custom object and set the parameters based on the selection. I'm sure there are calls for you to let the user choose something, and they will highlight the objects the user hovers, as this is default VW behaviour. Quote Link to comment
VvierA Posted December 10, 2015 Author Share Posted December 10, 2015 @Hippocode Wow, very cool. I don't know, if I can handle this, but I will try. Thank you very much. Quote Link to comment
Miguel Barrera Posted December 14, 2015 Share Posted December 14, 2015 I'd like the following usage: - select the tool - hover over the drawing with the cursor - VW should highlight the graphic elements while I hover (could be everything - not necessarily a custom object) - I click one one of the graphic elements while it is highlighted - my plugin object retrieves information of that element and my object is placed right there where I clicked - the plugin object shows information of the element like a stamp (for example the area of the element) Take a look at the following procedure for the hovering functionality: http://developer.vectorworks.net/index.php/VS:TrackObject the definition also includes a working sample. 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.