【问题标题】:Working in a ready-made iam with Inventor api c#使用 Inventor api c# 在现成的 iam 中工作
【发布时间】:2022-11-14 12:24:34
【问题描述】:

使用Inventor api c#,我设法根据指定的位置将2个ipt和1个iam文件转储到一个iam文件中。现在我想使用拉伸切割在交叉点切割重叠的轮廓。我正在尝试为此使用必要的代码,但我经常在配置文件部分收到此错误。 错误:System.ArgumentException:'参数不正确。 (HRESULT 返回异常:0x80070057 (E_INVALIDARG))'

我该如何解决这个问题?你能帮我吗 。

     Application application1 = (Inventor.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application");
            string openIam = "C:\\Users\\User\\Documents\\Assembly1.iam";




            string fullpath1 = "C:\\Users\\USER\\DesktoP\\part1.iam";
            string fullpath2 = "C:\\Servers\\part.iam";

            var documentOpen = _application.Documents.Open(openIam, true);

            documentOpen.UnitsOfMeasure.LengthUnits = UnitsTypeEnum.kMillimeterLengthUnits;
            var StartDoc = _application.ActiveDocument as AssemblyDocument ;


   
            AssemblyComponentDefinition oAsmCompDef = StartDoc.ComponentDefinition;




            TransientGeometry transientGeometry = _application.TransientGeometry;

            int inputIpt1X = Convert.ToInt16(kapi1xkonum.Text);

            int inputIpt2X = int.Parse(kapi2xkonum.Text);

            int kapi1X = inputIpt1X + 75;
            int kapi2X = inputIpt2X + 75;

            Matrix matrix1 = transientGeometry.CreateMatrix();

            
            matrix1.SetTranslation(transientGeometry.CreateVector(kapi1X, 0, 0));



            string kapi1 = openFileDialog1.FileName;
            ComponentOccurrence oOcc1;
            oOcc1 = oAsmCompDef.Occurrences.Add(kapi1, matrix1);

            Matrix matrix2 = transientGeometry.CreateMatrix();


            matrix1.SetTranslation(transientGeometry.CreateVector(kapi2X, 0, 0));

            string kapi2 = openFileDialog2.FileName;
            ComponentOccurrence oOcc2;
            oOcc2 = oAsmCompDef.Occurrences.Add(kapi2, matrix1);

 
            Matrix matrix3 = transientGeometry.CreateMatrix();


            matrix3.SetTranslation(transientGeometry.CreateVector(0, 0, 0));
            ComponentOccurrence oOcc3;
            oOcc3 = oAsmCompDef.Occurrences.Add(fullpath1, matrix2);

            PlanarSketch sktch = oAsmCompDef.Sketches.Add(oAsmCompDef.WorkPlanes["XY Plane"], true);

            Profile oProfile = sktch.Profiles.AddForSolid();

            var cornerPointOne = transientGeometry.CreatePoint2d(20, 10);
            var cornerPointTwo = transientGeometry.
                CreatePoint2d(90, 10);

            _currentSketch.SketchLines.
                AddAsTwoPointRectangle(cornerPointOne, cornerPointTwo);


            var extrudeDef = oAsmCompDef.Features.ExtrudeFeatures.
                CreateExtrudeDefinition(oProfile,
                PartFeatureOperationEnum.kCutOperation);
            extrudeDef.SetDistanceExtent(42, PartFeatureExtentDirectionEnum.kPositiveExtentDirection);
            oAsmCompDef.Features.ExtrudeFeatures.Add(extrudeDef);


            StartDoc.SaveAs(fullpath2, false);

【问题讨论】:

    标签: autodesk-inventor


    【解决方案1】:

    创建草图后添加sktch.Edit()

    然后在添加草图线后添加 sktch.ExitEdit(),然后再创建拉伸特征。

    【讨论】:

      猜你喜欢
      • 2021-09-10
      • 2015-08-31
      • 2011-12-13
      • 1970-01-01
      • 1970-01-01
      • 2021-01-22
      • 2015-06-05
      • 1970-01-01
      • 2022-10-18
      相关资源
      最近更新 更多