MetaCase Homepage
Forum Home Forum Home > > MetaEdit+
  New Posts New Posts RSS Feed - API: place information
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

API: place information

 Post Reply Post Reply
Author
Message
Andres View Drop Down
Member
Member


Joined: 29.Jun.2011
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote Andres Quote  Post ReplyReply Direct Link To This Post Topic: API: place information
    Posted: 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
Back to Top
rise View Drop Down
MetaCase
MetaCase


Joined: 31.Mar.2008
Points: 22
Post Options Post Options   Thanks (0) Thanks(0)   Quote rise Quote  Post ReplyReply Direct Link To This Post Posted: 30.Jun.2011 at 13:17
Hi Andrés!

Originally posted by Andres Andres wrote:

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?
 
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

Back to Top
Andres View Drop Down
Member
Member


Joined: 29.Jun.2011
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote Andres Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
rise View Drop Down
MetaCase
MetaCase


Joined: 31.Mar.2008
Points: 22
Post Options Post Options   Thanks (0) Thanks(0)   Quote rise Quote  Post ReplyReply Direct Link To This Post Posted: 01.Jul.2011 at 14:15
Hi Andrés,

Originally posted by Andres Andres wrote:

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?


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
Back to Top
Andres View Drop Down
Member
Member


Joined: 29.Jun.2011
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote Andres Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.05
Copyright ©2001-2022 Web Wiz Ltd.

This page was generated in 0.039 seconds.