@darioschmidt wrote:
Hi,
I need get the positions of the node ports when the user drop a shape from stencil. To do this, i am using the diagram listener 'ExternalObjectsDropped'. The problem is the position of the ports always is invalid.Listener
// Shape drop this.diagram.addDiagramListener('ExternalObjectsDropped', e => { this.shapeDropListener(e); }); private shapeDropListener(e: DiagramEvent): void { // Location of the node const location = e.diagram.selection.first().data.location; const shape: Shape = <Shape>(e.diagram.selection.first().data); if (!shape) { return; } // Cancels drop e.diagram.commandHandler.deleteSelection(); e.diagram.currentTool.doCancel(); // Obtains unique name const nodeName: string = this.getUniqueName(shape); // Creates new node const node: Node = this.configuratorService.getNewNode(this.modelView, shape, nodeName, location); e.diagram.model.addNodeData(node); // Add links var n = e.diagram.findNodeForKey(node[this.configuratorService.getNodeKeyProperty()]); const panel = <Panel>n.findObject('NODEPANEL'); if (!panel) { return; } panel.itemArray.forEach((port: Port) => { const portPart = panel.findItemPanelForData(port).findObject('PORT'); console.log(portPart.getDocumentPoint(go.Spot.Center)); }); }I can obtain the parts of each port of the node added, but the position of the part is invalid.
I have added the same code in the mouseEnter property of the node and now the value of the port position is ok. Maybe the problem is related with the transaction.
Thanks, Dario
Posts: 2
Participants: 2