AnsweredAssumed Answered

Unable to use Sketch.RelationManager.[I]AddRelation in C# / COM app

Question asked by Vladas Sidlauskas on Oct 31, 2014

Hello,

 

I want to add a coincident relationship between SketchPoint mySketchPoint and SketchLine mySketchLine using Sketch.RelationManager.[I]AddRelation in C# / COM app (SW2013 SP3)

I tried:

 

object []Objects = new object[2];

 

Objects[0] = mySketchPoint;

Objects[1] = mySketchLine;

 

int RelationNo = (int)swConstraintType_e.swConstraintType_COINCIDENT;

 

Sketch mySketch = (Sketch)this.SWModel.SketchManager.ActiveSketch;

 

mySketch.RelationManager.AddRelation(Objects , RelationNo);

// gives 'System.Runtime.InteropServices.COMException'

 

mySketch.RelationManager.IAddRelation(2, ref Objects , RelationNo);

// gives 'System.InvalidCastException'

 

AddRelation argumens are (object Entities, int RelationType)

IAddRelation arguments are (int NumEntities, ref object EntityArray, int RelationType)

 

Any hint is very welcome.

 

Regards,

Vladas S.

Outcomes