2013-12-05 3 views
0

Я tring, чтобы нарисовать линию C# в Illustrator с последующим кодом. Независимо от того, куда отправляются координаты точки, она всегда рисует одну и ту же линию от 0,0 до 10, -10.Нарисуйте линию, используя C# automation в Illustrator

 // x1,y1 x2,y2 are point coordinates 
     // doc is the active document 

     var myLine = Doc.PathItems.Add(); 
     myLine.Left = Math.Min(x1, x2); 
     myLine.Top = Math.Min(y1, y2); 

     //set stroked to true so we can see the path 
     myLine.Stroked = true; 

     var newPoint = myLine.PathPoints.Add(); 
     newPoint.Anchor[0]=x1; 
     newPoint.Anchor[1]=y1; 
     //giving the direction points the same value as the 
     //anchor point creates a straight line segment 
     newPoint.LeftDirection = newPoint.Anchor; 
     newPoint.RightDirection = newPoint.Anchor; 
     newPoint.PointType = AiPointType.aiCorner; 

     var newPoint1= myLine.PathPoints.Add(); 
     newPoint1.Anchor[0] = x2; 
     newPoint1.Anchor[1] = y2; 
     newPoint1.LeftDirection = newPoint1.Anchor; 
     newPoint1.RightDirection = newPoint1.Anchor; 
     newPoint1.PointType = AiPointType.aiCorner; 

Этот код из документа Adobe VB, преобразованного в C#.

Edit: Я предполагаю, что проблема возникает из

 newPoint.Anchor[0]=x1; 
     newPoint.Anchor[1]=y1; 

Это было newPoint.anchor = [x1, y1] в VB версии. Как правильно перевести его на C#? В документации указано, что newPoint.Anchor - это Variant Array из 2 двухместных.

ответ

0

Пятнистый!

Чтобы установить вариант массив в C# раствор

newPoint.Anchor = new object[] { x1,y1 };