Create construction circle in code

Creator
Creator

Question: How to toggle a created circle from profile to construction? Or how to create circle that is already construction? I've tried, but my code doesn't work

 

 

Documents documents = app.Documents;
PartDocument partDocument = documents.AddPartDocument();
app.DoIdle();
RefPlanes refPlanes = partDocument.RefPlanes;
Sketchs sketches = partDocument.Sketches;
RefPlane refPlane = refPlanes.GetFrontPlane();

Sketch sketch = sketches.Add();
Profile profile = sketch.Profiles.Add(refPlane);

// Create elements
Circle2d circle1 = profile.Circles2d.AddByCenterRadius(0, 0, DIAMETER_CIRCLE_1 / 2);
Circle2d circle2 = profile.Circles2d.AddByCenterRadius(0, 0, DIAMETER_CIRCLE_2 / 2);

// Execute command "Toggle to Construction" for selected objects
app.ActiveSelectSet.Add(circle1);
app.ActiveSelectSet.Add(circle2);
app.StartCommand(LayoutInPartCommandConstants.LayoutInPartToolsConstruction);
app.ActiveSelectSet.RemoveAll();

 q1.png

 

2 REPLIES

Re: Create construction circle in code

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Hi kavit,

don't use the select set and StartCommand()!

The Profile object has a method ToggleConstruction(Element)

to change to construction and back. Use your created circle1 object as parameter.

  

    profile.ToggleConstruction(circle1)

    ....

 

You can also query the construction status by

profile.IsConstructionElement(Element)

 

regards JB

regards

JB
VS2015, SE ST10

Re: Create construction circle in code

Creator
Creator

Awesome, thanks !