//각 Constraint에서 사용하는 Master/Slave Part의 ReferenceName을 refCommand 구조체로 리턴 private refCommand TestRefer(TransCAD.IStdAssemConstraint tConstraint, CTYPE i) //constrain 받아오기 { CTYPE type = i; refCommand para = new refCommand(); refCommand result = new refCommand(); ReferenceClass.ref_Post m_refer = new ReferenceClass.ref_Post(); switch (type) { case CTYPE.Coaxial: TransCAD.IStdAssemConstraintCoaxial coax = (TransCAD.IStdAssemConstraintCoaxial)tConstraint; Console.WriteLine("Loading Coaxial......................................"); para.command = (int)type; para.param = "Axis" + ":("; para.MasterPart = coax.ConstrainedPart.Name; para.SlavePart = coax.ReferencePart.Name; para.MasterPart_Ref = coax.ConstrainedGeometry.ReferenceeName; para.SlavePart_Ref = coax.ReferenceGeometry.ReferenceeName; break; case CTYPE.Incidence: TransCAD.IStdAssemConstraintIncidence coin = (TransCAD.IStdAssemConstraintIncidence)tConstraint; Console.WriteLine("Loading INCIDENCE......................................"); para.command = (int)type; para.param = ""; para.MasterPart = coin.ConstrainedPart.Name; para.SlavePart = coin.ReferencePart.Name; para.MasterPart_Ref = coin.ConstrainedGeometry.ReferenceeName; para.SlavePart_Ref = coin.ReferenceGeometry.ReferenceeName; break; /* Mutahar 18-10-09 * case CTYPE.Angle: //(Surface-Surface) * TransCAD.IStdAssemConstraintAngle ang = (TransCAD.IStdAssemConstraintAngle)tConstraint; * Console.WriteLine("Loading Angle......................................"); * * para.command = (int)type; * para.param = ""; * para.MasterPart = ang.ConstrainedPart.Name; * para.SlavePart = ang.ReferencePart.Name; * para.MasterPart_Ref = ang.ConstrainedGeometry.ReferenceeName; * para.SlavePart_Ref = ang.ReferenceGeometry.ReferenceeName; * Angle Value? * * break; * case CTYPE.Distance: //(Surface-Surface) * TransCAD.IStdAssemConstraintCoaxial Dist = (TransCAD.IStdAssemConstraintDistance)tConstraint; * Console.WriteLine("Loading Distance......................................"); * * para.command = (int)type; * para.param = ""; * para.MasterPart = dist.ConstrainedPart.Name; * para.SlavePart = dist.ReferencePart.Name; * para.MasterPart_Ref = dist.ConstrainedGeometry.ReferenceeName; * para.SlavePart_Ref = dist.ReferenceGeometry.ReferenceeName; * Offset Value? * * break; */ default: Console.WriteLine("Anything........"); break; } Console.WriteLine("////////////////////////////////////////////////////////////////////////"); result = m_refer.ConvertRefPost(para); Console.WriteLine("////////////////////////////////////////////////////////////////////////"); Console.WriteLine("ConsNum : " + result.command.ToString()); Console.WriteLine("master : " + result.MasterPart_Ref); Console.WriteLine("slave : " + result.SlavePart_Ref); Console.WriteLine("////////////////////////////////////////////////////////////////////////"); return(result); }
//각 part 들을 .CATScript로 변한하여 path에 저장함 public void TranslatePartsT2C_Script(int CompNum, int PartNum, string path) { ReferenceClass.ref_Post m_refer = new ReferenceClass.ref_Post(); m_refer.AssemblyPartT2C(CompNum, PartNum, path);//CompNum,PartNum,filePath : 몇번째 Comp의 몇번째 Part를 filePath에 .CATScript로 변환해서 넣겠다. }
//각 Constraint에서 사용하는 Master/Slave Part의 ReferenceName을 refCommand 구조체로 리턴 private refCommand TestRefer(TransCAD.StdAssemConstraint tConstraint, CTYPE i, PreStack _stack) //constrain 받아오기 { CTYPE type = i; refCommand para = new refCommand(); refCommand result = new refCommand(); ReferenceClass.ref_Post m_refer = new ReferenceClass.ref_Post(); m_refer.Set_stack_info(_stack); double value = 0; //Type Define TransCAD 7.0 /* * TransCAD.StdAssemblyConstraintType.StdAssemblyConstraintType_Angle; * TransCAD.StdAssemblyConstraintType.StdAssemblyConstraintType_Coaxial; * TransCAD.StdAssemblyConstraintType.StdAssemblyConstraintType_Coincidence; * TransCAD.StdAssemblyConstraintType.StdAssemblyConstraintType_Distance; * TransCAD.StdAssemblyConstraintType.StdAssemblyConstraintType_Fix; * TransCAD.StdAssemblyConstraintType.StdAssemblyConstraintType_Parallel; * TransCAD.StdAssemblyConstraintType.StdAssemblyConstraintType_Perpendicular; */ switch (type) { case CTYPE.StdAssemblyConstraintType_Coaxial: TransCAD.StdAssemConstraintCoaxial coax = (TransCAD.StdAssemConstraintCoaxial)tConstraint; Console.WriteLine("Loading Coaxial......................................"); _debug = coax.Name; para.command = (int)type; para.param = "Axis" + ":("; para.MasterPart = coax.ConstrainedPart.Name; para.SlavePart = coax.ReferencePart.Name; para.MasterPart_Ref = coax.ConstrainedEntity.ReferenceeName; _debug = coax.ConstrainedEntity.Name; ///[Edit]For test A1 TestRally 20190712 { //TransCAD.Reference tempref = coax.ConstrainedEntity; //bool res = tempref.IsPlanarFace; //if we get edge name we have to find surface that define axis if (para.MasterPart_Ref.IndexOf('#') != -1) { string[] _split = para.MasterPart_Ref.Split('#'); TransCAD.Part ptr = coax.ConstrainedPart; for (int s = 0; s < _split.Length; s++) { string temp = _split[s].Substring(_split[s].IndexOf(',', _split[s].IndexOf(',') + 1) + 1); TransCAD.Reference tempref = ptr.SelectBrepByName(temp); if (!tempref.IsPlanar) { para.MasterPart_Ref = _split[s]; break; } para.MasterPart_Ref = _split[s]; } } } para.SlavePart_Ref = coax.ReferenceEntity.ReferenceeName; _debug = coax.ReferenceEntity.Name; ///[Edit]For test A1 TestRally 20190712 { //if we get edge name we have to find surface that define axis if (para.SlavePart_Ref.IndexOf('#') != -1) { string[] _split = para.SlavePart_Ref.Split('#'); //para.SlavePart_Ref = _split[1]; //Method 2 : Find by name of 'Sketch' for (int j = 0; j < _split.Length; j++) { if (_split[j].IndexOf("Sketch") > 0) { para.SlavePart_Ref = _split[j]; } } } if (para.SlavePart_Ref.IndexOf('#') != -1) { string[] _split = para.SlavePart_Ref.Split('#'); TransCAD.Part ptr = coax.ReferencePart; for (int s = 0; s < _split.Length; s++) { string temp = _split[s].Substring(_split[s].IndexOf(',', _split[s].IndexOf(',') + 1) + 1); TransCAD.Reference tempref = ptr.SelectBrepByName(temp); if (!tempref.IsPlanar) { para.SlavePart_Ref = _split[s]; break; } para.SlavePart_Ref = _split[s]; } } } Console.WriteLine(coax.ConstrainedEntity.ReferenceeName + ".&&." + coax.ReferenceEntity.ReferenceeName); break; case CTYPE.StdAssemblyConstraintType_Coincidence: TransCAD.StdAssemConstraintCoincidence coin = (TransCAD.StdAssemConstraintCoincidence)tConstraint; Console.WriteLine("Loading COINCIDENCE......................................"); _debug = coin.Name; para.command = (int)type; para.param = ""; para.MasterPart = coin.ConstrainedPart.Name; para.SlavePart = coin.ReferencePart.Name; para.MasterPart_Ref = coin.ConstrainedEntity.ReferenceeName; para.SlavePart_Ref = coin.ReferenceEntity.ReferenceeName; Console.WriteLine(coin.ConstrainedEntity.ReferenceeName + ".&&." + coin.ReferenceEntity.ReferenceeName); break; // Mutahar 18-10-09 case CTYPE.StdAssemblyConstraintType_Angle: //(Surface-Surface) TransCAD.StdAssemConstraintAngle ang = (TransCAD.StdAssemConstraintAngle)tConstraint; Console.WriteLine("Loading Angle......................................"); _debug = ang.Name; para.command = (int)type; para.param = ""; para.MasterPart = ang.ConstrainedPart.Name; para.SlavePart = ang.ReferencePart.Name; para.MasterPart_Ref = ang.ConstrainedEntity.ReferenceeName; para.SlavePart_Ref = ang.ReferenceEntity.ReferenceeName; value = ang.Angle; Console.WriteLine(ang.ConstrainedEntity.ReferenceeName + ".&&." + ang.ReferenceEntity.ReferenceeName); //Angle Value? break; case CTYPE.StdAssemblyConstraintType_Distance: //(Surface-Surface) TransCAD.StdAssemConstraintDistance dist = (TransCAD.StdAssemConstraintDistance)tConstraint; Console.WriteLine("Loading Distance......................................"); _debug = dist.Name; para.command = (int)type; para.param = ""; para.MasterPart = dist.ConstrainedPart.Name; para.SlavePart = dist.ReferencePart.Name; para.MasterPart_Ref = dist.ConstrainedEntity.ReferenceeName; para.SlavePart_Ref = dist.ReferenceEntity.ReferenceeName; Console.WriteLine(dist.ConstrainedEntity.ReferenceeName + ".&&." + dist.ReferenceEntity.ReferenceeName); value = dist.Distance; //Offset Value? break; default: Console.WriteLine("Anything........"); break; } Console.WriteLine("////////////////////////////////////////////////////////////////////////"); result = m_refer.ConvertRefPost(para); result.option = value; Console.WriteLine("////////////////////////////////////////////////////////////////////////"); Console.WriteLine("ConsNum : " + result.command.ToString()); Console.WriteLine("master : " + result.MasterPart_Ref); Console.WriteLine("slave : " + result.SlavePart_Ref); Console.WriteLine("////////////////////////////////////////////////////////////////////////"); return(result); }