I am writing a plugin for AutoCAD in C#.
I would like to change the position of the pivot point of a group.
It is possible to do that by mouse clicking but after deselecting and reselecting the group, it automatically moves back to it's default position (which looks like it is the center point of the bounding box).
If I use something like...
private void SetBasePoint(Group group)
{
group.AnyAvailableMethod();
//or...
group.AnyAvailableAttribute;
}
...none of the offered attributes or methods give me any solution or hint how to get there.
Does anyone have a clue how to access the pivot?
-Mike
So after working through several APIs and websites I contacted Kean Walmsley from Autodesk Developer Network and even he told me there was no direct way to get access to the pivot of a group.
So now I'm saving a user defined basepoint inside AutoCAD and whenever I need a function with a predefined pivot position I simply call my own loadBasepoint() -method which fits perfectly for my specific case.
Just in case someone runs into the same issue I thought I'd mention it :)
Related
I am trying to get motivated to move one of my open source projects called Transparency Maker from Windows Forms to Blazor, so I can put the app online.
All of the image editing is done via text in a language called BQL (Bitmap Query Language) which is very similar to SQL.
The one thing I don't know how to do in Blazor is get the x, y position of where the image is clicked. Windows Forms makes this very simple, although I have to do some scaling.
Is there a JavaScript way of doing this and bringing it into Blazor?
This is a feature I have to have, or writing a query like this is impossible for the user to know what to type:
Update
Set Adjust Red -200
Where
X Between 1700 2591
Y Between 1930 2110
Total > 500
Notice the White part of the socks in the second image, only the white was changed because the Total (Red + Blue + Green) has to be greater than 500 to perform the adjustment.
Thanks if this is possible to get the position clicked?
I think more people might appreciate this tool once it is online. As it is, "selling" free software is actually harder than it should be.
Transparency Maker
https://github.com/DataJuggler/TransparencyMaker
I am posting an answer thanks to the help from dani (if you posted your answer here, I could mark it as the answer).
I had to do two things to make this work:
Add a using statement for
using Microsoft.AspNetCore.Components.Web;
I added the EventCallback e parameter, and I didn't have to change anything else.
public void Button_Clicked(MouseEventArgs e)
{
double x = e.ClientX;
}
I will probably have to write some trial and error code to go from where the image is located, to find what pixel was actually clicked, but now I am confident I can do this.
Many thanks Dani. I will name a hospital after you some day.
I am about to write a main menu for a Windows Forms application.
Rather than trying to explain my goal with a wall of text i made a quick(ugly) paint sketch:
As you can see here i want the Group Controls to automatically scale with their content(similar to the wrap_content attribute in android) and fit underneath each other if possible.
If anyone knows how to achieve this or even has a sample where he already did achieve it, that would help me massively!
thanks, Felix.
I am trying to create a WPF application using C# to run on Pixelsense that is basic version of the tangram puzzle. I am able to draw my 7 shapes and translate and rotate them all around the screen.
Could anyone give me advise regarding how I should go about saving the pattern (with shapes in specific positions and orientations) so that when a user creates the pattern next time, the application can match it to the saved one and tell the user if it's correct.
It's a pattern matching and recognition problem that I am trying to solve.
I have been stuck on this for a while now :(
Define the solution as a collection of objects with shapeType, position, and orientation properties. Have the solution include one shape at position 0, 0 and an orientation of 0. Now loop over all the shapes the user has actually placed to find the ones with a shapeType that matches the shape your solution has at 0,0,0. Calculate the position and orientation of every other shape relative to where the user put this one. Compare those values to the rest of your solution. You'll need to experiment with how much tolerance to allow because this stuff is not precise - to make the game fun, err on the side of having high tolerances. If needed, you can follow this up with some performance optimizations to only re-evaluate pieces that moved.
Hopefully you are using physical shape prices with tags on them instead of this purely a virtual game. I always wanted to build this when I was on the Surface team but it never happened. One challenge you will run into is defining how the tag's position/orientation relates to the actual shape. If you'll be putting tag stickers on multiple tangram sets, you almost certainly won't get the on precisely the same each time so you may need to add a "calibration" mode to your app (have the user place each piece in a specific spot and then push a button so you can record where the tag is relative to those spots). The TagVisualizer WPF control should help a lot for building your UI - definitely look into using it (this scenario was top of mind when we designed that API). The default behavior of that control (if you tell it the ID of a tag to look for but not how to visualize it) is a "crosshair" that can help you find tune your offset values.
Good luck! If you wouldn't mind recording a YouTube video when you are done and posting a comment here linking to it, I'd really appreciate that
You can use ObservableCollection or List of a custom class. That class can consist of various values such as position, orientation etc as properties.
When a new pattern is drawn or when the pattern change its position you can update that particular object stored in the collection. As you have all the details of the pattern(positions and orientation) you can iterate the for loop and check the position of the new pattern when added.
I'm working on a Add-in for PowerPoint 2010 (C#) and I want to prevent the end-user to move or edit all the shapes that I have programmatically created.
I have already sought in the framework but I think it's not allowed programmaticaly. Has anyone already encountered this kind of limitations and could help me to find a solution?
I know that some people create their add-in thanks to C++ because there are a lot of limitations in office.
I have found two solutions :
The first is to catch all events from the "commandBars.OnUpdate" like this great sample code : http://code.msdn.microsoft.com/CSExcelNewEventForShapes-0e26b1f2#content
Then you can impose the position/the color or everything you want to your shape.
The second one is more "brutal" > unselect immediately the shape. When you catch all the events from the "CommandBars.OnUpdate" do this :
To see which shape is selected :
var selectedShape = this.Application.ActiveWindow.Selection.ShapeRange[1]
In all my shapes, I have set a tag with an ID. I have just to check that there are an ID in the tags of the selectedShape and if this is the case :
this.Application.ActiveWindow.Selection.Unselect();
Then I show a messageBox to warn the user to do not select this kind of shape.
I don't like this solution but it's the only one that I have found and it works.
I believe this is not possible. A way of achieving this to a certain extent (people can work around it if they figure out how to select the shapes below) is by making a transparent rectangle the size of the canvas and binding a custom event to that (like you described in your comment). The transparent rectangle is overlaying the shapes you created so people can no longer access the shapes that way. Of course if they are capable of figuring out how to select the shapes they can move them anyway...
Alternatively, to make people not do stuff like that (you only stop the inexperienced) you can also set them up as master slides.
Only 'real' solution for people not doing that? Images .. but then they can move the image too!
I'd like to design a UI-Element, which gives the User the possibility to switch between different options. Therefore I want to use a Tangible which acts as control dial... I have already designed a Pointer and a Menu. The problem:
When the User rotates the Tangible, the Menu should stand still and the pointer should follow the rotation-movement. But when the User just moves the Tangible (without a rotation), the whole UI-Element should move.
Here a example for a non-Tangible control dial:
http://msdn.microsoft.com/en-us/library/ee804832%28v=surface.10%29.aspx
Does anyone know how to deal this with a TagVisualization?
Thanks in advance,
Chris
EDIT:
I've written a small tutorial, which can be viewed on: http://project-premium.org/
Set UsesTagOrientation=false on the TagVisualization or TagVisualizationDefinition
Inside the TagVisualization, monitor TrackedContact.Orientation to update your dial UI