14 Replies Latest reply on Jan 24, 2013 10:19 PM by Joecel Torres

    Set Fillet dimension to Driven

    Joecel Torres

      Hello!

           Solidworks automatically creates a radius dimension when a fillet is created.

           How do I set that radius dimension into driven?

           Thanks!

       

      Regards,

      Joecel 

        • Re: Set Fillet dimension to Driven
          Keith Rice

          Joecel,

           

          In our Macro Library is a macro called "Change driven / driving state of selected dimensions". This should help you out. Downloading it requires a free membership at my site, FYI.

           

          Keith

          Video Tutorials for the SolidWorks API

            • Re: Set Fillet dimension to Driven
              Joecel Torres

              Keith,

                   Are you talking about the Dimension:: DrivenState function?

                   I already used in on the other part of my program.

                   As you have said, this function works on selected dimension.

                   My problem in the radius dimension is that I cannot find a way to select it.

                   Solidworks automatically create it so I cannot initialize it then use the SelectByID2.

               

              Regards,

              J.Torres

                • Re: Set Fillet dimension to Driven
                  Keith Rice

                  I don't even see an option on fillet radii dimensions to change them to driven.  This code seems like it should change the driven state but it does not:

                   

                  Dim swApp As SldWorks.SldWorks

                  Dim swModel As SldWorks.ModelDoc2

                  Dim swDim As SldWorks.Dimension

                  Dim swDispDim As SldWorks.DisplayDimension

                   

                  Sub main()

                      Set swApp = Application.SldWorks

                      Set swModel = swApp.ActiveDoc

                      Set swDim = swModel.Parameter("D1@Fillet1")

                      swDim.DrivenState = swDimensionDriven

                      Debug.Print swDim.DrivenState

                  End Sub

                   

                  This may be a limitation with fillet radii dimensions. Anyway, by using IModelDoc2::Parameter, you do not need to select the dimension.

                   

                  Keith

                  Video Tutorials for the SolidWorks API

                    • Re: Set Fillet dimension to Driven
                      Joecel Torres

                      Keith,

                           The name of the radius dimension is not definite so I need to identify its name before using the ModelDoc2:: Parameter method.

                           I will try to look for workaround, hope I can find a solution.

                           Thanks for your hint!

                       

                      Regards,

                      Joecel

                        • Re: Set Fillet dimension to Driven
                          Keith Rice

                          Once you have the IFeature pointer for the fillet feature, use IFeature::GetFirstDiplayDimension to get the IDisplayDimension object and then you're set. Below I also print the fillet name, that way if for some reason you did want to use IModelDoc2::Parameter or IModelDocExtension::SelectByID2, you would know the fillet's name.

                           

                          ========

                           

                          Dim swApp As SldWorks.SldWorks

                          Dim swModel As SldWorks.ModelDoc2

                          Dim swPart As SldWorks.PartDoc

                          Dim swFeat As SldWorks.Feature

                          Dim swDispDim As SldWorks.DisplayDimension

                          Dim swDim As SldWorks.Dimension

                           

                          Sub main()

                              Set swApp = Application.SldWorks

                              Set swModel = swApp.ActiveDoc

                              Set swPart = swModel

                              Set swFeat = swPart.FeatureByName("Fillet1")

                              Set swDispDim = swFeat.GetFirstDisplayDimension

                              Set swDim = swDispDim.GetDimension2(Empty)

                              swDim.DrivenState = swDimensionDriven

                              Debug.Print swDispDim.GetNameForSelection

                          End Sub

                           

                          ========

                           

                          Anyway, I'm still not even sure you can make a fillet dimension "driven" at all but if you could, this is how you would do it.

                           

                          Keith

                          Video Tutorials for the SolidWorks API

                            • Re: Set Fillet dimension to Driven
                              Joecel Torres

                              Keith,

                                  

                                        SketchSegment fillet = swSktMngr.CreateFillet(currStageThickness, 1); 

                                        PartDoc part = (PartDoc)modelDoc;

                                       Feature feat = (Feature)part.FeatureByName("Arc6");

                                        dispDim = (DisplayDimension)feat.GetFirstDisplayDimension();

                                        Dimension dim = (Dimension)dispDim.GetDimension();

                                        dim.DrivenState = (int)swDimensionDrivenState_e.swDimensionDriven;

                               

                                         My code returns null when I use the PartDoc:: FeatureByName.

                                          I'm sure about the name but "Arc6" because I run a macro to get the name of the created fillet.

                                         I also tried the Feature:: FeatureById using the ID of the fillet but it returned the ID of the origin.

                                        

                              Regards,
                              J.Torres

                            • Re: Set Fillet dimension to Driven
                              Artem Taturevych

                              Would you like to change the input for your fillet to control it with other conditions rather than fillet radius. For example the height of fillet face? If so you should use the equations and make the fillet radius driven by other conditions/equations.

                               

                              The issue is the only parameter for fillet considered by SolidWorks is Fillet Radius and you cannot change it. If you still like to see your fillet dimension as driven (usually greyed out). You can hide this one and create new driven dimension of your fillet edge. In general this workaround may 'fake' your goal.

                              __________________________

                              Regards,

                              Artem Taturevych

                              Application Engineer at Intercad

                              http://intercad.com.au/

                              Tel: +61 2 9454 4444

                                • Re: Set Fillet dimension to Driven
                                  Joecel Torres

                                  Artem,

                                       No, I would like to set my radius dimension to driven so that my drawing will not be 'Over Defined'.

                                       My current output sketch is over defined and my client instructed me to set the radius dimension to driven.

                                       I also thought of deleting the automatically created radius dimension then create another one, but the problem is I do not

                                       know how to select the automatically created radius dimension for me to be able to use the ModelDoc2:: EditDelete function.

                                       Can you help me figure out how to select it?

                                       Thanks!

                                   

                                  Regards,

                                  J.Torres

                                    • Re: Set Fillet dimension to Driven
                                      Artem Taturevych

                                      Excuse me I'm a bit confused of what you like to achieve and what the problem do you have. Why your sketch is overdefined? Are you trying to create another dimension on top of fillet radius? Can you create video or something like that of the problem do you have and what you like to achieve?

                                        • Re: Set Fillet dimension to Driven
                                          Joecel Torres

                                          Artem,

                                               Due to some constraints and relations done by the program, the output became overdefined.

                                               And to fix this, I need to set the fillet dimension to Driven to make it Fully Defined.

                                               I am not trying to create a dimension on top of a radius, I just need to set it to Driven.

                                               Please see the attached file for what I want to achieve.

                                           

                                          Regards,

                                          J.Torres

                                            • Re: Set Fillet dimension to Driven
                                              Artem Taturevych

                                              Joecel,

                                               

                                              Ok, it now makes sense because you are talking about sketch fillet but we though that you are talking about feature fillet.

                                               

                                              Here the code which will help. It will make the driven dimension for newly added sketch fillet. Because of this:

                                               

                                              https://forum.solidworks.com/thread/63471 the solution is not very elegant.

                                               

                                              public partial class SolidWorksMacro

                                              {

                                               

                                                  public void Main()

                                                  {

                                                      ModelDoc2 model = swApp.IActiveDoc2;

                                                      SketchSegment seg = model.SketchManager.CreateFillet(0.01, (int)swConstrainedCornerAction_e.swConstrainedCornerDeleteGeometry);

                                                      IFeature sketch = (IFeature)seg.GetSketch();

                                                     

                                                      DisplayDimension dispDim = (DisplayDimension)sketch.GetFirstDisplayDimension();

                                                      while (dispDim != null)

                                                      {

                                                          Annotation ann = dispDim.IGetAnnotation();

                                                          System.Collections.Generic.List<object> attEnts

                                                              = new System.Collections.Generic.List<object>((object[])ann.GetAttachedEntities3());

                                                          if (attEnts.Contains(seg))

                                                          {

                                                              Dimension dim = dispDim.IGetDimension();

                                                              dim.DrivenState = (int)swDimensionDrivenState_e.swDimensionDriven;

                                                              break;

                                                          }

                                                          dispDim = (DisplayDimension)sketch.GetNextDisplayDimension(dispDim);

                                                      }

                                               

                                                      //to update the view

                                                      model.ViewRotateminusx();

                                                      model.ViewRotateplusx();

                                                  }

                                               

                                                  public SldWorks swApp;

                                              }

                                              __________________________

                                              Regards,

                                              Artem Taturevych

                                              Application Engineer at Intercad

                                              http://intercad.com.au/

                                              Tel: +61 2 9454 4444

                                                • Re: Set Fillet dimension to Driven
                                                  Joecel Torres

                                                  Artem,

                                                       Your 'while' loop will iterate all the DisplayDimension on the sketch right?

                                                       The raduis dimension I'm talking about is not the only DisplayDimension on this sketch.

                                                       Different dimension have been created before this.

                                                       So there's a big possibility that different DisplayDimension from the sketch will be initialized to 'dispDim'

                                                       Is there a way for me to get the newly created dimension?

                                                       So that whenever the sketch fillet is created, I will call this method and initialize the created radius dimension to dispDim.

                                                   

                                                   

                                                  Regards,

                                                  J.Torres

                                                    • Re: Set Fillet dimension to Driven
                                                      Artem Taturevych

                                                      Have you tried this code? If you look into the code I'm not setting all the dimensions to the driven state.

                                                       

                                                      System.Collections.Generic.List<object> attEnts

                                                      = new System.Collections.Generic.List<object>((object[])ann.GetAttachedEntities3());

                                                                 if (attEnts.Contains(seg))

                                                      {

                                                                     Dimension dim = dispDim.IGetDimension();

                                                      dim.DrivenState = (int)swDimensionDrivenState_e.swDimensionDriven;

                                                                     break;

                                                      }


                                                      The above statement allows to find only the dimension which is attached to this sketch segment. Please read the solution I suggested you before in the post I referred - that's its implementation.

                                                       

                                                      You can also find a newly created dimension by collecting all the dimensions before executing and after executing - the difference is newly created dimensions.

                                                      __________________________

                                                      Regards,

                                                      Artem Taturevych

                                                      Application Engineer at Intercad

                                                      http://intercad.com.au/

                                                      Tel: +61 2 9454 4444