Community
PowerShape and PowerMill API Forum
Welcome to Autodesk’s PowerShape and PowerMill API Forums. Share your knowledge, ask questions, and explore popular API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

create a fitted arc in a Powershape Macro (not using the API)

0 REPLIES 0
Reply
Message 1 of 1
luc_ponsaerts
240 Views, 0 Replies

create a fitted arc in a Powershape Macro (not using the API)

Hi all,

 

I have a Powershape model, with multiple mesh models. On each model I have to create a fitted arc, by clicking three times on a model (to create the fitted arc). The fitted arc function has to be terminated (for a specific reason) before creating the fitted arc on the next model. That seems to be a problem.

In the macro I have :

QUICK QUICKSELECTMESHONLY
LIST all_models = {}
INT num_models = selection.number
INT sel = $num_models
IF $num_models > 0 {
    WHILE $sel {
         $sel = $sel - 1
         LET sel_name = selection.object[$sel].name
         select clearlist
         add Symbol $sel_name
         // now pick 3 points on the selected model to create a fitted arc
         CREATE ARC FITTED
         PARTIAL
         INPUT FREE

         OK
    }
}
The OK in the last line is not seen by the system after ending the INPUT FREE function.

 

In the API software the arc fitting function is (C#) :

 

/// <summary>

/// Creates an Arc by allowing the user to sketch through three points

/// </summary>

/// <param name="interval">The time in milliseconds between each check to see if the curve has been created yet</param>

/// <returns>Arc created by the operation</returns>

public PSArc SketchArcThroughThreePoints(int interval = 500)

{

     // Start the sketch

     _powerSHAPE.DoCommand("CREATE ARC FITTED");

 

     // Clear the created items list

     _powerSHAPE.ActiveModel.ClearCreatedItems();

 

     PSArc arc = null;

     PSModel model = _powerSHAPE.ActiveModel;

 

     // Keep looping and picking points

     while (arc == null)

     {

         // Wait for half a second to see if a arc has been created yet

         System.Threading.Thread.Sleep(interval);

 

         // Fire in "OK" every time because if the user has finished sketching they have to confirm the radius before the creation completes

         _powerSHAPE.DoCommand("OK");

 

         // See if the user finished creating the arc yet

         if (model.CreatedItems.Count == 1)

         {

             arc = (PSArc) model.CreatedItems[0];

 

             // Call select to end the arc creation

             _powerSHAPE.DoCommand("SELECT");

 

             // Add the new arc to the collection

             model.Arcs.Add(arc);

         }

     }

 

     return arc;

}

 

One can see here that the "OK" parameter is constantly sent in a loop wit a delay  of 500 msec.

So, I suspect that we have to find a way to do a similar thing in the macro?

 

I am curious to know if there isn't a more sensible way.

 

luc

0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums