Thanks, I'm asking about ways to interact with the text: getting, setting.
Latest posts made by ittayd
-
RE: Weird DimensionLinear behavior
-
RE: Bounds change depending on active context?
I think the docs do mention returning coordinates in model space. I read "model space" to mean a global standard coordinate system. So I would expect the coordinates to never change no matter what entity is opened.
And, I wouldn't mind the coordinates changing if
contains?
would have acted sanely, always returning true to a point that is inside the group -
RE: Knowing the ComponentInstance a DimensionLinear is attached
dim.start[0]
will return a Vertex or Edge. How do I know the ComponentInstancedim.start[0]
is part of? As I wrotedim.start[0].parent
returns a ComponentDefinition. -
Bounds change depending on active context?
I created a rectangle, grouped it and then grouped the group.
I select the inner group and print its bound's corners:
I then select the outer group and print the inner group's bounds corners again:
The values change.
My problem is that I have a point (the start of a dimension) that is then deemed outside of the bounding box of the group:
But if I open the outer group, it is OK:
How can I make sense out of this?
-
Knowing the ComponentInstance a DimensionLinear is attached
I have a dimension attached to a component instance (it moves with it, changes when it is stretched, etc.). Using the API,
dim.start[1].parent
returns a ComponentDefinition. This of course doesn't tell me which instance it is attached to. Is there a way of knowing? Or is it a bug?(A brute force method is to go over every instance, iterate over all its vertices and compare with the one of the dimension. I'm looking for something more elegant, and that will work when attaching to an edge etc.)
-
Weird DimensionLinear behavior
Dimensions that are inside components change their texts based on the instance scale. This is true in the GUI as well as the API.
For example, in the images below, the rectangles are instances of the same component. I open the left one, get a dimension entity and its text and then open the right one and get the text of the same entity which changed. A similar thing happens for positioning
Is there a way to get all texts of the dimension instance? Is there a way of programmatically change one?
(I'm using SU 17.2.2555)
-
Undo model observer - when to remove?
I want to attach a ModelObserver to react to onTransactionUndo (is that the right approach to undo an operation when there's more than geometry?). But when do I remove it? Is there a way to know the limit of the undo stack and when my operation is out of it?
-
RE: Flags parameter in a tool's onKeyDown/Up
@dan rathbun said:
@ittayd said:
Hitting ctrl+shift as ctrl, keeping pressed and then shift:
onKeyDown prints 11101 on hitting ctrl, note again the flags mean both ctrl and shift are down
onKeyDown prints 101010 on hitting shift (when the ctrl is still down) which suggests it "forgets" the shift is down.It seems you are making a fundamental mistake. In this example in the quote above, the detected KEY is the SHIFT key, and it is what is causing the
onKeyDown()
callback to fire, and it's keycodeVK_SHIFT
will be stored in thekey
argument.So, then you do not detect IT within the
flags
bitfield, because you already know what the firing key is.Instead, at this point in time, you check the
flags
bitfield for whatever other modifiers are associated with this press of the SHIFT key.OK, so you took just the last line of a whole example:
- When I press'shift' only, without 'ctrl' first, I get 101010. As if ctrl is pressed, but it is not.
- And even with the 'ctrl' pressed first, what is the meaning of the 6th and 2nd bits?
- When I press 'ctrl' only, without shift, I get 11101, as if ctrl and shift are pressed.
- And also, what is the meaning of the 5th and 1st bits?
- I get the same codes in onKeyDown and onKeyUp regardless of whether I press ctrl with shift already pressed or not or when I press shift and ctrl is pressed before or not.
And sure, the 'key' parameter does hold the code for ctrl and shift, and I ended up maintaining an instance variable to flip bits on and off when the callbacks are called. But I'm still confused as to the meaning of the flags parameter.
I'd like to mention that I have 16 years of professional programming: 1.5 years of Ruby, 8 years Java, 2 years of Scala, 5 years of C/C++ and in particular 1 year of Linux kernel development (in the virtual memory handling subsystem), as well as other assorted languages. In particular, I had many chances of doing bit manipulation of variables as well as work with bit sets.
All of that doesn't help me in understand the values of the flags parameter which in the case of onKeyDown/onKeyUp doesn't make sense to me. For comparison, in onLButtonDown, the flags are 1001 if ctrl is down when the button is clicked, 101 if shift is down and 1101 if both and just 1 when nothing is pressed. These are consistent with showing the value of the modifier keys, but inconsistent with the values I listed in my original post.
-
RE: Flags parameter in a tool's onKeyDown/Up
@dan rathbun said:
@ittayd said:
onKeyDown prints 101010 on hitting shift (when the ctrl is still down) which suggests it "forgets" the ctrl is down.
Why do you say this, when it is clear that the 4th bit (for CTRL modifier) is set ?
Typo. ctrl should be shift. But it is pretty obvious from the other examples (as well as this one) that the flags values are probably the bit set they were meant to be
-
RE: Flags parameter in a tool's onKeyDown/Up
@dan rathbun said:
Re-reading your original post the second paragraph is not at all clear. Ie: Run-on sentences. Not stating what callback (onKeyUp/onKeyDown) you are referencing.
Sorry if my message wasn't clear, English is not my native language (I don't even know what run-on sentences mean) and I wrote the post after a couple of hours of frustration. I edited it to make it clearer
I couldn't find code that demonstrated the use of flags in onKeyDown or onKeyUp (including searching my plugins folder, github, google).