Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - cristian.ignat

Pages: [1]
1
Suggestions and Requests / Re: arranging ports in a diagram via script
« on: September 25, 2018, 09:41:01 pm »
Still does not fix my problem.

2
Suggestions and Requests / Re: arranging ports in a diagram via script
« on: September 25, 2018, 08:07:27 pm »
I was less interested in the way you calculated the position rather than how you update the data in the DB.

q.

This is how I add an element to a diagram.The ports are already part of the component and they seem to automatically snap to the component they belong to.

Code: [Select]
private DiagramObject addElement(Diagram d, Element e,String position) {

//Adds a diagram object (port or component) to the diagram given

DiagramObject newDiagramObject;


newDiagramObject = d.GetDiagramObjects().AddNew(position, "");



newDiagramObject.SetElementID(e.GetElementID());

if(!newDiagramObject.Update()) {
System.out.println(newDiagramObject.GetLastError());
}
repository.SaveDiagram(d.GetDiagramID());
repository.ReloadDiagram(d.GetPackageID());

newDiagramObject.Update();

d.Update();
d.GetDiagramObjects().Refresh();


return newDiagramObject;
}

3
Suggestions and Requests / Re: arranging ports in a diagram via script
« on: September 25, 2018, 04:48:50 pm »
"7" seems to be an important magical number  ;)

I used 7 because from what I read from the scripting manual a port is 15 by 15 pixels. One pixel in the middle that is on the margin plus 7 in all direction gives a 15 by 15 square... If I am not wrong   :D

Geert

4
Suggestions and Requests / Re: arranging ports in a diagram via script
« on: September 25, 2018, 04:08:00 pm »
I have just tried with 1309 and it appears to work. Can you post your code so we can eventually spot the bug?

q.

This is the class responsible for the position of the ports. At the constructor it gets a point in the top middle margin and from there it starts to go around the component.
Code: [Select]
private class portPosition{
Side side;
double l,r,t,b;
int portSpacing = 50;
Point M;
componentPosition cp;
public portPosition(Point Middle, componentPosition cp) {
side = Side.top;
this.cp = cp;
this.M = Middle;
l=M.getX()-7;
r=M.getX()+7;
t=M.getY()+7;
b=M.getY()-7;

new Point(l,t);
new Point(r,b);
}
public String getFormatedPosition() {
StringBuilder sb = new StringBuilder();
sb.append("l=").append(l).append(";r=").append(r).append(";t=").append(t).append(";b=").append(b);
//"l="+l+";r="+r+";t="+t+";b="+b;
return sb.toString();
}

public void nextPosition() {
switch(side) {
case top:
if(cp.getRight()>M.getX()+portSpacing) {
M.setX(M.getX()+portSpacing);
l=M.getX()-7;
r=M.getX()+7;
System.out.println("top "+getFormatedPosition());
}else {
M.setX(cp.getRight());
M.setY(cp.getTop());
this.side = Side.right;
l=M.getX()-7;
r=M.getX()+7;
t=M.getY()+7;
b=M.getY()-7;
System.out.println("top next"+getFormatedPosition());
//this.nextPosition();
}
break;
case right:
if(cp.getBottom()<M.getY()-portSpacing) {
M.setY(M.getY()-portSpacing);
t=M.getY()+7;
b=M.getY()-7;
System.out.println("right "+getFormatedPosition());
}else {
M.setY(cp.getBottom());
M.setX(cp.getRight());
this.side = Side.bottom;
l=M.getX()-7;
r=M.getX()+7;
t=M.getY()+7;
b=M.getY()-7;
System.out.println("right next "+getFormatedPosition());
//this.nextPosition();
}

break;

case bottom:
if(cp.getLeft()<M.getX()-portSpacing) {
M.setX(M.getX()-portSpacing);
l=M.getX()-7;
r=M.getX()+7;
///System.out.println("bottom "+getFormatedPosition());

}else {
M.setX(cp.getLeft());
M.setY(cp.getBottom());
this.side = Side.left;
l=M.getX()-7;
r=M.getX()+7;
t=M.getY()+7;
b=M.getY()-7;
System.out.println("bottmon next "+getFormatedPosition());
//this.nextPosition();

}
break;

case left:
if(cp.getTop()>M.getY()+portSpacing) {
M.setY(M.getY()+portSpacing);
l=M.getX()-7;
r=M.getX()+7;
System.out.println("left "+getFormatedPosition());
}
else {
M.setX(cp.getLeft());
M.setY(cp.getTop());
this.side = Side.top;
l=M.getX()-7;
r=M.getX()+7;
t=M.getY()+7;
b=M.getY()-7;
System.out.println("left next "+getFormatedPosition());
//this.nextPosition();
}
break;
default: System.out.println("Default case");
break;
}
}

@SuppressWarnings("unused")
public int getLeft() {
return (int)l;
}
@SuppressWarnings("unused")
public int getRight() {
return (int) r;
}
@SuppressWarnings("unused")
public int getTop() {
return (int)t;
}
@SuppressWarnings("unused")
public int getBottom() {
return (int)b;
}
}
private enum Side{
top,
right,
bottom,
left
}

5
Suggestions and Requests / Re: arranging ports in a diagram via script
« on: September 24, 2018, 04:22:34 pm »
I work on version 13.0.1309. Do you know if this version in specially is affected ? Unfortunately I cannot update

6
Suggestions and Requests / arranging ports in a diagram via script
« on: September 24, 2018, 04:08:23 pm »
Hello!

I am trying to automatically generate some diagrams with components that have ports. I've tried a lot of arranging systems for the ports but none seem to work. The ports seem to all go to one spot or randomly place themselves on a margin from the component they belong to even tough the coordinates set for the ports are exactly on the margin of the component (i used the system explained in the scripting book of EA: the port is 15 pixels wide and 15 pixel high, and the center sport is on the margin of the component).
I have tried offsetting them by a set amount of pixels but is still would not work.

If anyone can help, I would be grateful!

Pages: [1]