コード例 #1
0
        protected override void OnSetDimensions(ISldWorks app, IModelDoc2 model, IFeature feature, MacroFeatureRebuildResult rebuildResult,
                                                DimensionDataCollection dims, DimensionMacroFeatureParams parameters)
        {
            var rebuildRes = rebuildResult as CustomRebuildResult;

            var customData = rebuildRes.CustomData;

            //TODO: use custom data to arrange dimensions
        }
コード例 #2
0
 private void UpdateDimensions(ISldWorks app, IModelDoc2 model, IFeature feature,
                               MacroFeatureRebuildResult rebuildRes, IDisplayDimension[] dispDims, string[] dispDimParams, TParams parameters)
 {
     using (var dimsColl = new DimensionDataCollection(dispDims, dispDimParams))
     {
         if (dimsColl.Any())
         {
             OnSetDimensions(app, model, feature, rebuildRes, dimsColl, parameters);
         }
     }
 }
コード例 #3
0
        protected override void OnSetDimensions(ISldWorks app, IModelDoc2 model, IFeature feature, MacroFeatureRebuildResult rebuildResult,
                                                DimensionDataCollection dims, BodiesFilletFeatureDataModel parameters)
        {
            var filletRebuildRes = rebuildResult as BodiesFilletMacroFeatureRebuildResult;

            var filletFace = filletRebuildRes.FilletFaces.FirstOrDefault() as IFace2;

            if (filletFace != null)
            {
                var surf = filletFace.IGetSurface();

                var uvBounds = filletFace.GetUVBounds() as double[];
                var evalData = surf.Evaluate(
                    (uvBounds[0] + uvBounds[1]) / 2,
                    (uvBounds[2] + uvBounds[3]) / 2, 0, 0) as double[];

                var pt   = new Point(evalData[0], evalData[1], evalData[2]);
                var norm = new Vector(evalData[evalData.Length - 3], evalData[evalData.Length - 2], evalData[evalData.Length - 1]);

                Vector axis = null;

                if (surf.IsCylinder())
                {
                    var cylParams = surf.CylinderParams as double[];
                    axis = new Vector(cylParams[3], cylParams[4], cylParams[5]);
                }
                else if (surf.IsTorus())
                {
                    var torParams = surf.TorusParams as double[];
                    axis = new Vector(torParams[3], torParams[4], torParams[5]);
                }

                var rad = parameters.Radius;

                var moveDir = new Vector(norm);
                moveDir.Scale(-1);

                var dimStartPt = pt.Move(moveDir, rad);

                dims[0].SetOrientation(dimStartPt, axis);
            }
        }
コード例 #4
0
        protected override void OnSetDimensions(ISldWorks app, IModelDoc2 model, IFeature feature,
                                                DimensionDataCollection dims, RoundStockFeatureParameters parameters)
        {
            var stockModel = ServicesContainer.Instance.GetService <RoundStockModel>();

            var cylParams = GetCylinderParams(model, parameters);

            var startPt   = new Point(cylParams.Origin.ToArray());
            var heightDir = new Vector(cylParams.Axis.ToArray());
            var endPt     = startPt.Move(heightDir, cylParams.Height);

            Vector diamDir = null;

            var yVec = new Vector(0, 1, 0);

            if (heightDir.IsSame(yVec))
            {
                diamDir = new Vector(1, 0, 0);
            }
            else
            {
                diamDir = yVec.Cross(heightDir);
            }

            var startExtraDiamPt = endPt.Move(diamDir, cylParams.Radius - parameters.ExtraRadius);

            var diamExtVec = diamDir.Cross(heightDir);

            dims[(int)RoundStockFeatureDimensions_e.Radius].Dimension.SetDirection(endPt, diamDir, cylParams.Radius, diamExtVec);
            dims[(int)RoundStockFeatureDimensions_e.Radius].Dimension.DrivenState = (int)swDimensionDrivenState_e.swDimensionDriven;
            dims[(int)RoundStockFeatureDimensions_e.Radius].Dimension.ReadOnly    = true;

            dims[(int)RoundStockFeatureDimensions_e.Height].Dimension.SetDirection(startPt, heightDir, cylParams.Height);
            dims[(int)RoundStockFeatureDimensions_e.Height].Dimension.DrivenState = (int)swDimensionDrivenState_e.swDimensionDriven;
            dims[(int)RoundStockFeatureDimensions_e.Height].Dimension.ReadOnly    = true;

            dims[(int)RoundStockFeatureDimensions_e.ExtaRadius].Dimension.SetDirection(
                startExtraDiamPt, diamDir, parameters.ExtraRadius);
        }
コード例 #5
0
 /// <summary>
 /// Override this function to configure the dimensions of macro feature (i.e. position, style, etc.)
 /// </summary>
 /// <param name="app">Pointer to application</param>
 /// <param name="model">Pointer to current model</param>
 /// <param name="feature">Pointer to macro feature</param>
 /// <param name="dims">Pointer to dimensions of macro feature</param>
 /// <param name="parameters">Current instance of parameters (including the values of dimensions)</param>
 /// <remarks>Use the <see cref="DimensionDataExtension.SetOrientation(DimensionData, Point, Vector)"/>
 /// helper method to set the dimension orientation and position based on its values</remarks>
 protected virtual void OnSetDimensions(ISldWorks app, IModelDoc2 model, IFeature feature,
                                        MacroFeatureRebuildResult rebuildResult, DimensionDataCollection dims, TParams parameters)
 {
     OnSetDimensions(app, model, feature, dims, parameters);
 }
コード例 #6
0
 /// <inheritdoc cref="OnSetDimensions(ISldWorks, IModelDoc2, IFeature, MacroFeatureRebuildResult, DimensionDataCollection, TParams)"/>
 protected virtual void OnSetDimensions(ISldWorks app, IModelDoc2 model, IFeature feature,
                                        DimensionDataCollection dims, TParams parameters)
 {
 }
コード例 #7
0
        protected override void OnSetDimensions(ISldWorks app, IModelDoc2 model,
                                                IFeature feature, MacroFeatureRebuildResult rebuildResult, DimensionDataCollection dims,
                                                DimensionMacroFeatureParams parameters)
        {
            dims[0].SetOrientation(new Point(0, 0, 0), new Vector(0, 1, 0));

            dims[1].SetOrientation(new Point(0, 0, 0), new Vector(0, 0, 1));
        }
コード例 #8
0
        protected override void OnSetDimensions(ISldWorks app, IModelDoc2 model, IFeature feature,
                                                MacroFeatureRebuildResult rebuildResult, DimensionDataCollection dims, BoundingCylinderMacroFeatureParams parameters)
        {
            Point  center;
            Vector axis;
            double radius;
            double height;
            double extraHeight;

            GetCylinderParameters(parameters, out center, out axis, out radius, out height, out extraHeight);

            var dimOrig = center.Move(axis, height);

            var dimDir = new Vector(axis);

            dims[0].SetOrientation(dimOrig, dimDir);
        }