get shape of the element added

Hi,
how can I get the shape of the item (node or connector) which is being added into the diagram space. I know that collectionChange event fired but I am not
not able to get the shape. I am adding my code here
collectionChange(args: ICollectionChangeEventArgs) {
    let obj = args.element;
    if (args.state === 'Changed') {
          //checking if node is added
                if (obj instanceof Node) {
                console.log(args.element.shape); //here I am not getting
     }
     //checking if connector 
     else{
       console.log(args.element.shape)
     }
}

Thanks in advance

1 Reply

AR Aravind Ravi Syncfusion Team March 2, 2020 11:38 AM UTC

Hi Rakhi, 
 
The “type” property of the node shape allows you to get the “Shape” of the newly added node.  Please find the below code snippet for how to get shape for newly added item in diagram 
 
public collectionChange(args: ICollectionChangeEventArgs) { 
     
    if (args.state === "Changed") { 
      if (args.element instanceof Node) { 
        console.log(args.element.shape.type); 
        let shape: string = args.element.shape.type; 
        switch (shape) { 
          case "Flow": 
            console.log((args.element.shape as FlowShapeModel).shape); 
            break; 
          case "Basic": 
            console.log((args.element.shape as BasicShapeModel).shape); 
            break; 
        } 
      } else if (args.element instanceof Connector) { 
        console.log(args.element.segments[0].type); 
      } 
    } 
  } 
 
We have created a simple sample to get the shape of newly added item. Please find the sample in below link 
 
 
Regards 
Aravind Ravi 


Loader.
Up arrow icon