7 Replies Latest reply on Feb 14, 2013 7:06 PM by Ioan Bordei

    Circle sketch verification

    Ioan Bordei

      Hello!

      I have the following code:

       

      VARIANT_BOOL bIsArc=FALSE;

      double radius;

      CComPtr<ISketchArc> pArc;

       

      hr=pArc->SetRadius(radius,&bIsArc);

       

      All the time I modify the radius of the 2D arc with two tangent constrains, the bIsArc has the same value (in this case TRUE), even if the geometrical construction is not possible. How could I check if a pArc is valid or not when I change the radius?

      I have try to check hr and if(pArc!=NULL) but they are also are all the time ok!.

      The idea is to modify only the arc radius taking into account the two constraints, but the construction of the arc to be mathematically correct! If the radius exceed the permitted value I must find a way to track the error.

      Ioan

        • Re: Circle sketch verification
          Artem Taturevych

          Do you mean you like to found whether the sketch segment is overdefind after the setting of radius?

            • Re: Circle sketch verification
              Ioan Bordei

              Exactly!

              I like to increase the radius up to an overdefine error! I must cycle for values and nothing can stop my code to finish! :-)

              I'm not sure what is the best method, is possible to coding in COM something similar to smart dimenions for dimension the selected circle?

                • Re: Circle sketch verification
                  Artem Taturevych

                  Unfortunately sketch segment itself's doesn't have a property whether it is overrefined or not. However after changing the radius you can check the state of the sketch where this segment resides: Sketch::GetConstrainedStatus (values defined in swConstrainedStatus_e enumerator). Based on the status before applying the radius and after you may have a decision whether this change affects the sketch's status.

                  __________________________

                  Regards,

                  Artem Taturevych

                  Application Engineer at Intercad

                  http://intercad.com.au/

                  Tel: +61 2 9454 4444

                    • Re: Circle sketch verification
                      Ioan Bordei

                      The sketch is created in a Drawing document.

                       

                      CComPtr<ISketchManager> swSketchMgr;

                      hr = pModel->get_SketchManager(&swSketchMgr);

                      if (hr != S_OK) { return; }

                       

                      // Get active sketch

                      CComPtr<ISketch> swSketch;

                      hr = swSketchMgr->get_ActiveSketch(&swSketch);

                      if (hr != S_OK) { return; }

                       

                      //here is impossible to construct

                      hr=pArc->SetRadius(0.08,&IsFitted);

                      swSketch->GetConstrainedStatus(&retval);

                      //here is OK to construct

                      hr=pArc->SetRadius(0.27,&IsFitted);

                      swSketch->GetConstrainedStatus(&retval);

                      //here is impossible to construct

                      hr=pArc->SetRadius(1,&IsFitted);

                      swSketch->GetConstrainedStatus(&retval);

                       

                      All the time I get retval = 2   - swUnderConstrained..

                       

                      I'm not sure but can pArc->SetRadius() be consider a constrain?

                      In the code, internally, the add-on doesn't react like in overdefind sketch situation, when the radius is too big to mathematically construct the circle, this situation is simply ignored by the system, with no error, SW simply remember the last valid value input. SeRadius seems to be very simple to implement, there are other alternatives?