none
Unable to rotate Line shape in particular angle in PPT RRS feed

  • Question

  • I have created a Line shape in PPT but i am unable to rotate it in particular angle.

    Below is code block

    D.Outline outline = new D.Outline(
    				new D.SolidFill(new D.RgbColorModelHex() { Val = lineColor.ToRGBHex() }),
    				new D.PresetDash() { Val = D.PresetLineDashValues.Solid }) // solid line
    			{
    				Width = (Int32)(lineWidth * ShapeUtilites.EMUPerPoint),
    				CapType = D.LineCapValues.Round,
    				CompoundLineType = D.CompoundLineValues.Single,
    				Alignment = D.PenAlignmentValues.Center,
                     
    			};
    
    
                shape.ShapeProperties.Append(
                    new D.PresetGeometry(new D.AdjustValueList()) { Preset = D.ShapeTypeValues.Line },
                    new D.NoFill(),
                    outline,
                    new D.EffectList());
                
    			shape.NonVisualConnectionShapeProperties = new P.NonVisualConnectionShapeProperties(
    				new P.NonVisualDrawingProperties() { Id = this.shapeId, Name = this.shapeName },
    				new P.NonVisualConnectorShapeDrawingProperties(),
    				new P.ApplicationNonVisualDrawingProperties());

    Thanks

    Ankur

    Monday, October 24, 2016 1:44 PM

Answers

  • Hi,

    I suggest you use Open XML SDK Tool to compare files, then you could generate the code you want. You could download it from https://www.microsoft.com/en-us/download/details.aspx?id=30425

    In this case, to set the rotation of a shape, you could use something like code below. 

    600000 is 10°.

    using A = DocumentFormat.OpenXml.Drawing;
       public  void ChangeSlidePart(SlidePart slidePart1)
            {
                Slide slide1 = slidePart1.Slide;
     
                CommonSlideData commonSlideData1=slide1.GetFirstChild<CommonSlideData>();
     
                ShapeTree shapeTree1=commonSlideData1.GetFirstChild<ShapeTree>();
     
                ConnectionShape connectionShape1=shapeTree1.GetFirstChild<ConnectionShape>();
     
                ShapeProperties shapeProperties1=connectionShape1.GetFirstChild<ShapeProperties>();
     
                A.Transform2D transform2D1=shapeProperties1.GetFirstChild<A.Transform2D>();
                transform2D1.Rotation = 600000;
            }

     

    In your code, I think it should look like:

      D.Transform2D transform2D1 = new D.Transform2D(){ Rotation = 600000 };

      shape.ShapeProperties.Append(transform2D1)

    • Marked as answer by ankurastogi Wednesday, January 11, 2017 6:37 PM
    Tuesday, October 25, 2016 5:30 AM
    Moderator