Change Position of a shape

Hello,

I have problems to move some shapes.
In my case I add a Can ( The Database Shape) and want to change its position. With another shape, the Ballon, I have the same problem.

long idDose = dgm.AddShape(new Shape(), “Can”, 0);
var dose = dgm.Pages[0].Shapes.GetShape(idDose);
dose.Name = “Dose54”;

I try:
dose.MoveTo(20, 20);

dose.Move(20, 20);

dose.XForm.PinX.Value = 20;
dose.XForm.PinY.Value = 5;
with no effect.

regards
Chris

Hi Chris,


Thanks for your inquiry. Could you please ensure that the database shape names are spelled correctly? Because I could not find these shapes. Second, please note that you don’t need to call move method right after adding a new shape. It does not help here. It is because overloaded AddShape methods allow you to adjust the shape’s location and width/height as well.

Please do let me know in case of any confusion or questions.

Hi,

the overload of the AddShape Methode with x,y, doesnt work, too.
But this works:

var doseNew = new Shape();
doseNew.XForm.PinX.Value = 2;
doseNew.XForm.PinY.Value = 2;
long id = Diagramm.AddShape(doseNew, “Can”, 0);

but its not possible to change the position after the shape is added.

Yes it is spelled correctly, try the code with the attached file and code:
Diagram dgm = new Diagram(@“link.vsd”, LoadFileFormat.VSD);
dgm.AddMaster(“BASIC.vss”, “Dose”);

regards
chris

Hi Chris,

Thank you sharing sample documents. Please try the following source code below:

// load diagram

Diagram diagram = new Diagram("link.vsd", LoadFileFormat.VSD);

// Adds master to diagram from template file by master's Name or NameU

diagram.AddMaster("BASIC.vss", "Dose");

// Adds shape with defined PinX and PinY.

diagram.AddShape(2.0, 2.0, "Dose", 0);

diagram.AddShape(6.0, 6.0, "Dose", 0);

// Adds shape with defined PinX,PinY,Width and Height.

diagram.AddShape(7.0, 3.0, 1.5, 1.5, "Dose", 0);

// save file

diagram.Save("Output.vdx", SaveFileFormat.VDX);

I hope It helps. I have attached output VDX file your reference. Please do let me know in case of any confusion or questions.