MetaCase Homepage
Forum Home Forum Home > > MetaEdit+
  New Posts New Posts RSS Feed - Adding a BindingRepresentation through the API
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Adding a BindingRepresentation through the API

 Post Reply Post Reply
Author
Message
Simon_VM View Drop Down
Contributor
Contributor


Joined: 29.Nov.2011
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote Simon_VM Quote  Post ReplyReply Direct Link To This Post Topic: Adding a BindingRepresentation through the API
    Posted: 29.Nov.2011 at 22:39
Hello,

I've created a small language for production systems (these production systems can assemble APC's) using MetaEdit+, and I'm trying to simulate my models using the API. One of the things that needs to be done is that an operator needs to be moved to another machine. The relationship looks like this:

MachineOperator --> MachineOperatorToProcessor --> Processor

I can remove the old binding and its representation, as well as create a new one. However, I cannot create a new representation for it. My code runs just fine, but when I try to open my model in MetaEdit+, it gives me the following error:

"Unhandled exception: Message not understood: #-

Press Proceed (if shown) to attempt to ignore the error and continue.
..."

The proceed option doesn't work and I'm basically left with a corrupted model. I cannot open the diagram representation anymore, the matrix representation however does still work. It shows there that the new binding has been created (so the operator conceptually moved, it just can't show it for some reason).

Here is the relevant part of my code (I'm working in Python with the suds library). 'self.instance' is the object MEOop of the operator, 'self.parent.diagram' is the diagram representation MEOop of the Graph I'm working on. The objectID and areaID of the binding are hardcoded for performance reasons. Obviously this will have to change, but they are the correct values.


relRep = client.factory.create('ns0:MEOop')
relRep.areaID = 11
relRep.objectID = 2426
           
place = client.service.place(relRep)           
client.service.remove(relRep)
           
relationType = client.factory.create('ns0:METype')
relationType.name = 'MachineOperatorToProcessor'
role0 = client.factory.create('ns0:METype')
role0.name = 'toProcessor'
role1 = client.factory.create('ns0:METype')
role1.name = 'fromOperator'
binding = client.service.createBinding(self.parent.instance, relationType, [role0, role1], [self.instance, nextProcessor.instance])
client.service.addNewBindingRepFor(self.parent.diagram, binding, 1, place)


Can someone tell me what I'm doing wrong?

Thanks!
Back to Top
stevek View Drop Down
MetaCase
MetaCase
Avatar

Joined: 11.Mar.2008
Points: 643
Post Options Post Options   Thanks (0) Thanks(0)   Quote stevek Quote  Post ReplyReply Direct Link To This Post Posted: 29.Nov.2011 at 23:01
Just a quick check before looking into the details: do you have the reprCreationAPI.mep patch?
 
If you post (or email metaedit.support@metacase.com) the meplus0.err file, that will give us more information.
 
Thanks,
Steve
Back to Top
Simon_VM View Drop Down
Contributor
Contributor


Joined: 29.Nov.2011
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote Simon_VM Quote  Post ReplyReply Direct Link To This Post Posted: 29.Nov.2011 at 23:09
Yes, I forgot to tell you that I have installed the patch.

I have attached the meplus0.err file:
http://www.metacase.com/forums/uploads/294/meplus0.txt. Thanks for the help!
Back to Top
stevek View Drop Down
MetaCase
MetaCase
Avatar

Joined: 11.Mar.2008
Points: 643
Post Options Post Options   Thanks (0) Thanks(0)   Quote stevek Quote  Post ReplyReply Direct Link To This Post Posted: 30.Nov.2011 at 14:43
From the error log, it looks like the resulting BindingRep's place is null. The simplest cause for that would be that the place argument in the last line was null (presumably an MEAny containing an MENull)? Given that you're getting the place from a hard-coded MEOop, perhaps that MEOop is long dead (or was never fully initialized)? The correct format for a place is an MEAny with meType=Point and meValue=10,20 (i.e. x,y - note no space after the comma).
Back to Top
stevek View Drop Down
MetaCase
MetaCase
Avatar

Joined: 11.Mar.2008
Points: 643
Post Options Post Options   Thanks (0) Thanks(0)   Quote stevek Quote  Post ReplyReply Direct Link To This Post Posted: 30.Nov.2011 at 14:58
...and it looks like the API place method is returning an MEAny that doesn't fit that format - it adds single quotes around the meValue. So, for now the quickest solution is to remove any extra quotes from the meValue string you get back from the place(relRep) call. And of course we'll make sure that the conversion between Point and MEAny is corrected in the next release - thanks for pointing this out!
Back to Top
Simon_VM View Drop Down
Contributor
Contributor


Joined: 29.Nov.2011
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote Simon_VM Quote  Post ReplyReply Direct Link To This Post Posted: 01.Dec.2011 at 22:56
Thanks for your help, that seems to work! Smile
Back to Top
stevek View Drop Down
MetaCase
MetaCase
Avatar

Joined: 11.Mar.2008
Points: 643
Post Options Post Options   Thanks (0) Thanks(0)   Quote stevek Quote  Post ReplyReply Direct Link To This Post Posted: 02.Dec.2011 at 12:25
That's great, thanks for letting us know! And many thanks for reporting this, the fix is implemented and will be in the next 5.0 beta.
Back to Top
djuka View Drop Down
Major Contributor
Major Contributor
Avatar

Joined: 22.Jun.2011
Location: Germany
Points: 33
Post Options Post Options   Thanks (0) Thanks(0)   Quote djuka Quote  Post ReplyReply Direct Link To This Post Posted: 27.Apr.2012 at 11:50
Hello !

Does anybody maybe have C# function that uses API and:

- creates object;
- creates properties;
- sets some properties; and
- defines visual presentation  with one text (type) and one bitmap ?

It would save my time.

Regards,
Djuka
Back to Top
xingqing View Drop Down
Member
Member


Joined: 15.May.2012
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote xingqing Quote  Post ReplyReply Direct Link To This Post Posted: 15.May.2012 at 11:50
Thank you for all the things learned from here and congratulations for the good work.
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.031 seconds.