Example #1
0
        /// <summary>
        /// This is for Testing / Debuging purpose only
        /// </summary>
        private void ShowTestDialoges()
        {
            List <string> entetyNames = new List <string>();

            foreach (var sketchy in Partypart.SketchyList)
            {
                entetyNames.Add(sketchy.Name + ":\n");
                foreach (Inventor.SketchEntity ente in sketchy.SketchEntities)
                {
                    entetyNames.Add(ente.Type.ToString() + ", ");
                }
                entetyNames.Add("\n");
            }
            Debug.WriteLine(string.Join("", entetyNames));
            MessageBox.Show(string.Join("", entetyNames));

            List <string> parameterList      = new List <string>();
            Parameters    documentParameters = Partypart.InventorDocument.ComponentDefinition.Parameters;

            parameterList.Add("Name / Value / Comment");
            for (int i = 1; i < Partypart.InventorDocument.ComponentDefinition.Parameters.Count; i++)
            {
                try
                {
                    string             p1   = documentParameters[i].Name;
                    string             p2   = documentParameters[i]._Value.ToString(CultureInfo.InvariantCulture);
                    string             p3   = documentParameters[i].Comment;
                    Inventor.Parameter test = documentParameters[i];
                    parameterList.Add(p1 + " - " + p2 + " - " + p3 + "\n");
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.ToString());
                }
            }
            MessageBox.Show("ALLE PARAMETER: \n" + string.Join(",", parameterList));
        }
Example #2
0
        /// <summary>
        /// Everything you need to know about ExtrudeFeature
        /// </summary>
        /// <returns>List of "ExtrudeFeature"s</returns>
        public List <ExtrudeFeature> GetExtrudeFeatures()
        {
            PartComponentDefinition partComponentDefinition = InventorDocument.ComponentDefinition;
            List <ExtrudeFeature>   toReturn = new List <ExtrudeFeature>();

            foreach (ExtrudeFeature extrudeFeature in partComponentDefinition.Features.ExtrudeFeatures)
            {
                toReturn.Add(extrudeFeature);

                if (extrudeFeature.ExtentType == PartFeatureExtentEnum.kDistanceExtent
                    ) //wir können nur Distance extend benutzen!
                {
                    Inventor.Parameter param = (extrudeFeature.Definition.Extent as DistanceExtent)
                                               .Distance; //Value vorbereiten und unten dann abgreifen

                    var componentDefinition = extrudeFeature.Profile.Parent;

                    List <string> msg = new List <string>
                    {
                        extrudeFeature.ExtendedName, //z.B. "Neuer Volumenkörper x 17mm"
                        extrudeFeature.Name,         //z.B. "Extrusion1"
                        extrudeFeature.Profile.Type
                        .ToString(),                 //enthält das Profil (Profil.Parent sollte die Skizze enthalten)
                        extrudeFeature.ExtentType
                        .ToString(),                 // enthält die möglichen ExtentType typen. Z.B. kDistanceExtend, kThroughAllExtent, kFromToExtent, kToNextExtent. Wir gehen mal von kDistanceExtend aus - das ist das normale mit "17 mm" oder so.
                        extrudeFeature.Operation
                        .ToString(),                 // z.B. kNewBodyOperation, kIntersectOperation, kCutOperation, kJoinOperation
                        extrudeFeature.Definition.IsTwoDirectional
                        .ToString(),                 // bei der angabe kannste abbrechen da die Extrusion in beide richtungen geht. Es sind generell auch asyncrone Bidirektionale Extrude operationen möglich, ich weiß allerdings noch nicht inwiefern uns dieses eNum uns darüber informationen gibt
                        param._Value.ToString()      // ENDLICH! die Extrusion-Distance als double Value!
                    };
                    List <string> tmp = GetAffectedBodyNames(extrudeFeature);
                    if (tmp.Count != 0)
                    {
                        MessageBox.Show(String.Join(", ", tmp));
                    }
                }


                if (extrudeFeature.Definition.IsTwoDirectional)
                {
                    NotImplementedTypes.Add("extrudeFeature " + extrudeFeature.Name + ": IsTwoDirectional");
                }
                if (extrudeFeature.Profile.Count > 1)
                {
                    NotImplementedTypes.Add("extrudeFeature " + extrudeFeature.Name + ": Only 1 Profile per Sketch");
                }
                if (extrudeFeature.Operation != PartFeatureOperationEnum.kNewBodyOperation)
                {
                    NotImplementedTypes.Add(
                        "extrudeFeature " + extrudeFeature.Name + ": only kNewBodyOperation allowed");
                }
                if (extrudeFeature.ExtentType != PartFeatureExtentEnum.kDistanceExtent)
                {
                    NotImplementedTypes.Add("extrudeFeature " + extrudeFeature.Name + ": only kDistanceExtent allowed");
                }
            }

            return(toReturn);

            /*
             * foreach (PlanarSketch planarSketch in partComponentDefinition.Sketches)
             * {
             *  foreach (Profile planarSketchProfile in planarSketch.Profiles)
             *  {
             *      string b = "planarSketchProfile.AttributeSets.Type: " + planarSketchProfile.AttributeSets.Type + "\n";
             *      string c = "planarSketchProfile.Count: " + planarSketchProfile.Count + "\n";
             *      string d = "planarSketchProfile.Parent: " + planarSketchProfile.Parent.Type + "\n";
             *      string e = "planarSketchProfile.RegionProperties: " + planarSketchProfile.RegionProperties.Type + "\n";
             *      string f = "planarSketchProfile.Type: " + planarSketchProfile.Type + "\n";
             *      string g = "planarSketchProfile.Wires: " + planarSketchProfile.Wires.Type + "\n";
             *
             *      foreach (AttributeSet attributeSet in planarSketchProfile.AttributeSets)
             *      {
             *          attributeSet.
             *      }
             *      MessageBox.Show(b + c + d + e + f + g);
             *  }
             * }
             *
             * partComponentDefinition.Features.ExtrudeFeatures.AddByDistanceExtent(
             *  partComponentDefinition.Sketches[1].Profiles[1], "20 mm",
             *  PartFeatureExtentDirectionEnum.kNegativeExtentDirection, PartFeatureOperationEnum.kNewBodyOperation);
             *
             *
             * foreach (PartFeature partFeature in partComponentDefinition.Features)
             * {
             *  foreach (Inventor.Parameter partFeatureParameter in partFeature.Parameters)
             *  {
             *      MessageBox.Show(string.Join(", ", partFeature.Name, partFeature.ExtendedName, partFeatureParameter.Value, partFeatureParameter.Name, partFeatureParameter.ParameterType, partFeatureParameter.Expression));
             *  }
             * }
             *
             * partComponentDefinition.Features.ExtrudeFeatures.AddByToExtent(
             *  partComponentDefinition.Sketches[1].Profiles[1], "30 In", PartFeatureOperationEnum.kJoinOperation);*/
        }
Example #3
0
 public void updateAngleByParameter(int angle)
 {
     Inventor.Parameter invParam = nativeParameter;
     invParam.Value = Math.PI * angle / 180;
 }
Example #4
0
        } //end of method IntersectOperation

        private string ExtrudeSketch(ExtrudeFeature extrudeFeature)
        {
            StringBuilder extrusionLine = new StringBuilder();

            MasterM.ExtrudeDirection direction = MasterM.GetDirection(extrudeFeature);
            string objectName = extrudeFeature.Name;
            string name       = "Extrusion" + _numberOfSketches;

            if (direction == MasterM.ExtrudeDirection.Positive)
            {
                if (extrudeFeature.ExtentType == PartFeatureExtentEnum.kDistanceExtent)
                {
                    //get length of extrusion
                    Inventor.Parameter param              = (extrudeFeature.Definition.Extent as DistanceExtent).Distance;
                    double             length             = param._Value * factor;
                    string             paramString        = "params." + name;
                    Parameter          extrusionParameter = new Parameter(name, "Length of " + name, "float", length, 0.1);
                    ListOfParameter.Add(extrusionParameter);

                    //with parameter:
                    extrusionLine.Append("\t" + "var " + objectName + " = sketch" + _numberOfSketches + ".extrude({ offset: [0,0," + paramString + "] });");
                    //without parameter:
                    //extrusionLine.Append("\t" + "var " + objectName + " = sketch" + _numberOfSketches + ".extrude({ offset: [0,0," + height.ToString(myCultureInfo) + "] });");
                }
                else //default: extruding with 10
                {
                    extrusionLine.Append("\t" + "var " + objectName + " = sketch" + _numberOfSketches + ".extrude({ offset: [0,0,10] });");
                }
            }
            else if (direction == MasterM.ExtrudeDirection.Negative)
            {
                if (extrudeFeature.ExtentType == PartFeatureExtentEnum.kDistanceExtent)
                {
                    //because when extruding in openjscad you cant choose a direction
                    //we extrude in the same direction but then translating same length in reversed direction

                    //get length of extrusion
                    Inventor.Parameter param              = (extrudeFeature.Definition.Extent as DistanceExtent).Distance;
                    double             length             = param._Value * factor;
                    string             paramString        = "params." + name;
                    Parameter          extrusionParameter = new Parameter(name, "Length of " + name, "float", length, 0.1);
                    ListOfParameter.Add(extrusionParameter);

                    //with parameter:
                    extrusionLine.Append("\t" + "var " + objectName + " = sketch" + _numberOfSketches + ".extrude({ offset: [0,0," + paramString + "] })");
                    extrusionLine.Append(TranslateObject("z", paramString, true));

                    //without parameter:
                    //extrusionLine.Append("\t" + "var " + objectName + " = sketch" + _numberOfSketches + ".extrude({ offset: [0,0," + height.ToString(myCultureInfo) + "] });");
                    //extrusionLine.Append(TranslateObject("z", height.ToString(myCultureInfo), true));
                }
                else //default: extruding with 10
                {
                    extrusionLine.Append("\t" + "var " + objectName + " = sketch" + _numberOfSketches + ".extrude({ offset: [0,0,10] });");
                }
            }
            else //if(direction == ExtrudeDirection.Symetric)
            {
                //extrude distance
                //translate distance/2
            }

            return(extrusionLine.ToString());
        } //end of method ExtrudeSketch