calc port positions from library