- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @Rich-T. That is a relatively complex task to achieve by one iLogic rule.
The task of obtaining the location where you click your mouse, by itself, requires a whole additional large block of code that starts a very specific user interactions mode be started by the code at a certain point, then makes it wait while it monitors for specific actions to happen in the user interface area, then automatically reacts to a very specific action in a way that can capture that location. And even then, model space is 3D, while the mouse actions are relatively 2D, so there may be some projection involved.
I did create a rather large iLogic rule for this task, but it just attempts to center the TextBox at the center of the planar face you select. There are a lot of things that can be changed or personalized about this code routine, so you would have to review it carefully before trying it out, to see if changes may be needed to suit your specific situation. For instance:
- parts come in all shapes and sizes
- part faces can be pointing in any direction (may not necessarily be aligned with the UCS axes)
- TextBox can potentially be oriented in different directions
- Font, FontSize, Bold, Italic, UnderLine, Strikethrough options are available for edit by the custom Function
- There is a whole scrolling list of possible 'SHXfont' choices for the initial 'convert text to geometry' step
- It is using one simply named "txt" right now
- There is also an optional secondary step to the 'convert geometry to text' step, where you can specify if it should use a 'big font', and specify which one of those available ones to use for it.
- I did not include this second step in this code example, but it would be added into Line 49 as additional inputs.
- There are 2 MarkStyle objects that come installed with Inventor. Each one is for a different functionality (surface or through), and each one has its own settings other than that.
- If this is not set to the one you want, or you have a custom one, then you will have to edit that part of the code to find that other MarkStyle object, then, if it is a different type, you may have to change the other related options within the MarkDefinition below. (I left a couple lines commented out in that area.)
Anyways, the code is in the attached text file, because it is pretty long. As mentioned earlier, getting the location of your mouse click would mean getting rid of the 'Pick' method used in Line 2, then including a whole other custom block of code that you can call to run there, which will handle your face selection and/or the text location specification. There is an example or few here on this forum for that task by itself. Those types of large, special functionality blocks of code are usually stored as a separate rule, referenced from an external resource, or something like that, instead of all included in the same rule, for efficiency and reuse by other tasks later.
Wesley Crihfield
(Not an Autodesk Employee)