Print Page | Close Window

Adding a BindingRepresentation through the API

Printed From: MetaCase
Category:
Forum Name: MetaEdit+
Forum Description: All topics relating to MetaEdit+ or DSM
URL: https://www.metacase.com/forums/forum_posts.asp?TID=335
Printed Date: 27.Mar.2026 at 00:43
Software Version: Web Wiz Forums 12.05 - http://www.webwizforums.com


Topic: Adding a BindingRepresentation through the API
Posted By: Simon_VM
Subject: Adding a BindingRepresentation through the API
Date 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!



Replies:
Posted By: stevek
Date Posted: 29.Nov.2011 at 23:01
Just a quick check before looking into the details: do you have the %20http://www.metacase.com/support/45/program/#reprCreationAPI - reprCreationAPI.mep patch?
 
If you post (or email mailto:metaedit.support@metacase.com - metaedit.support@metacase.com ) the meplus0.err file, that will give us more information.
 
Thanks,
Steve


Posted By: Simon_VM
Date 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:
uploads/294/meplus0.txt - http://www.metacase.com/forums/uploads/294/meplus0.txt . Thanks for the help!


Posted By: stevek
Date 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).


Posted By: stevek
Date 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!


Posted By: Simon_VM
Date Posted: 01.Dec.2011 at 22:56
Thanks for your help, that seems to work! Smile


Posted By: stevek
Date 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 http://www.metacase.com/news/ME50.html - 5.0 beta .


Posted By: djuka
Date 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


Posted By: xingqing
Date Posted: 15.May.2012 at 11:50
Thank you for all the things learned from here and congratulations for the good work.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.05 - http://www.webwizforums.com
Copyright ©2001-2022 Web Wiz Ltd. - https://www.webwiz.net