Straightening relationship lines in #PowerDesigner

ER/Studio Data Architect allows you to remove all bends from a relationship symbol:

ER Studio - remove all bends

PowerDesigner has no equivalent, so I’ve just written one, as a demonstration of our ability to add functionality to what is already a great product.

I’ve added a ‘Straighten this line’ command to the contextual menu for individual links – it works in any type of model, on most types of link:

Straighten this line

Here’s an example before running the command:

Straighten this line - before

and afterwards – the line connects the same two points, and the corners have been removed:

Straighten this line - after

Here‘s how I did it

I added a new extension for all model types, which adds the ‘Straighten this line’ command for all symbols based on the ‘Polyline’:

PolylinePolyline menu

Here’s the tricky bit, the code for the method (which includes a set of output commands so you can see what it’s doing in the Script tab of the output window). The code has a few steps:

  • change the line style if necessary
  • If the line has more than just the beginning and end points
    • take a record of the coordinates of the destination point
    • remove all points except the first one
    • adds back the destination point
    • refreshes the diagram

Sub %Method%(obj)
‘changes the line style to “normal”, then removes all corners
output obj

if obj.CornerStyle <> “0” then obj.CornerStyle = “0” ‘ set the line style to straight

dim dest_point_X, dest_point_Y, Point_Count, current_point
point_count = obj.ListOfPoints.Count

if point_count > “2” then ‘ line has one or more corners
output ” – Initial points: ” & obj.ListOfPoints.AsText

‘ capture the values held in the destination point
dest_Point_X = obj.ListOfPoints.Item.X
dest_Point_Y = obj.ListOfPoints.Item.Y

current_point = Point_Count-1 ‘so that the first link point is not removed
do until current_point = 0
‘remove the last link point in the collection
current_point = current_point – 1

‘ add a new destination point
obj.ListOfPoints.AddPoint dest_Point_X, dest_Point_Y

output ” – Replaced by points: ” & obj.ListOfPoints.AsText

‘ Refresh the view
end if

End Sub

5 thoughts on “Straightening relationship lines in #PowerDesigner

  1. Eric Bless May 13, 2015 / 14:29

    Hi George,

    That is cool that the tool can be customized and extended, but for this specific functionality isn’t that what Right click > Disposition > Horizontal or Vertical do, or the rightmost 2 icons on the Layout toolbar?

    • George McGeachie May 13, 2015 / 15:27

      Hello Eric, thanks for responding
      I produced this extension today when I was specifcally asked how to make relationship lines straight, no matter where the entity symbols are on the diagram.
      There are three ways this is different from the standard horizontal/vertical alignment feature:
      1. it doesn’t move the end connectors at all
      2. it changes the line style to the only one that allows us to have lines with no corners
      3. the horizontal / vertical alignment feature only works on links where the joined symbols (e.g. entities) line up horizontally or vertically; this extension works on every link

      • Eric Bless July 22, 2015 / 12:46

        Thanks for the clarification, George. And good work!

  2. Andrey October 26, 2015 / 10:57

    In PowerDesigner 16.5 SP3 intermidiate points could also be removed by Ctrl + left mouse button clicking

    • George McGeachie October 26, 2015 / 12:44

      You’re right – that’s the manual way of doing it 🙂

Leave a Reply