![]() |
API: place information |
Post Reply
|
| Author | |
Andres
Member
Joined: 29.Jun.2011 Points: 3 |
Post Options
Thanks(0)
Quote Reply
Topic: API: place informationPosted: 29.Jun.2011 at 20:42 |
|
Hello everybody. I'm using the MetaEdit+ API from c#, and in general it works alright. I can loop through my graphs, objects, and properties without problems.
But now I wanted to get the placement (i.e. x and y) for an object in a graph, and I receive a marshalling error when I do so (MEAny place (MEOop receiver)). I tried asking first for the diagrams, that is ok, I get a list of diagrams. But anyway, using those diagrams as receiver for place() give me the same error as when I use the actual objects (for example, Button or Text) as receiver. Could somebody give me a hint on what is needed to find out the x,y location coordinates? Thanks in advance, Andrés |
|
![]() |
|
rise
MetaCase
Joined: 31.Mar.2008 Points: 22 |
Post Options
Thanks(0)
Quote Reply
Posted: 30.Jun.2011 at 13:17 |
|
Hi Andrés!
Without seeing your code I would assume that you are
trying to pass the conceptual objects as parameters where as the API is
expecting the object representations. Try out the following piece of code with
the Watch Example in the Demo repository to see if you can get a list of all
object places in 2008Models diagram without any troubles:
using System;
using System.Net;
using System.IO;
using System.Text;
using System.Collections;
using System.ComponentModel;
using System.Data;
public class APIClient
{
public static int
Main()
{
/// Set the variable and initialize
connection to MetaEdit+ API
MetaEditAPIPortTypeClient
meServer = new MetaEditAPIPortTypeClient();
/// Variable
holding "2008Models" graph's oid
MEOop wModels =
new MEOop();
wModels.areaID
= 22;
wModels.objectID
= 962;
/// Fetch the
diagrams for "2008Models"
MEOop[] diagrams = meServer.diagrams(wModels);
/// Fetch
object representations for first diagram
MEOop[]
objReprs = meServer.objectReprs(diagrams[0]);
/// Print out
the place for each object representation
foreach (MEOop
objRepr in objReprs)
{
Console.WriteLine("Place: " +
meServer.place(objRepr).meValue);
}
return 0;
}
}
If this does not clarify the situation, please send us
the problematic part of the code and we will look further.
With best regards,
Rise
|
|
![]() |
|
Andres
Member
Joined: 29.Jun.2011 Points: 3 |
Post Options
Thanks(0)
Quote Reply
Posted: 30.Jun.2011 at 17:58 |
|
Hi Rise, thank you very much! Your hint worked perfectly! It was my fault, I haven't understood that the receiver was supposed to be the representation, not the object itself. Then I also found the inst() method to figure out which is the object represented, so everything works as expected now!
The only issue that I couldn't resolve so far is the following: how do I find out the width and height of the representation? With the scale() method I get some clue, for example: "1.5, 2.0", but those are relative percentages. How can I find out the width and height in pixels for each drawn object? Thanks again! Andrés |
|
![]() |
|
rise
MetaCase
Joined: 31.Mar.2008 Points: 22 |
Post Options
Thanks(0)
Quote Reply
Posted: 01.Jul.2011 at 14:15 |
|
Hi Andrés,
As far as I know, there is currently (as of MetaEdit+ 4.5 SR1) no straight way to get that information via API. The trick is that the representation level does not contain or cache any other size information than scale for individual diagram elements. Internally the size is calculated by multiplying the symbol size with scale on the fly and this is probably what you have to do as well. So, check out the default sizes for each symbol at the Symbol Editor, cache this data in your C# program and use it to calculate the real size with scale information of each individual representation. However, be aware that you need to re-cache the symbol size information every time you change your symbols. With best regards, Rise Edit: And if you need to position that calculated "real" symbol area, be aware that the place location of the representation you get from the API is actually the place for symbol's default connectable's target point. Edited by rise - 01.Jul.2011 at 14:18 |
|
![]() |
|
Andres
Member
Joined: 29.Jun.2011 Points: 3 |
Post Options
Thanks(0)
Quote Reply
Posted: 01.Jul.2011 at 16:02 |
|
Hi Rise, thanks a lot for that info! I'll take a look at it.
Best regards, Andrés |
|
![]() |
|
Post Reply
|
|
| Tweet |
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |