I'm trying to access some collections/methods in my part document and I realized that some of them are available depending on the file is saved as ordered or synchronous.
It happens that when I have the part saved as synchronous I can access it's faces collection, but I'm unable to use the ExtrudedCutout.Suppress property. When I save it as ordered the problem reverses itself.
How do you experts deal with this problem???
Thanx a lot!
You can check the ModelingMode property of the PartDocument for Synchronous or Ordered mode, or better set it to Ordered mode BEFORE running your code.
In synchronous mode, you would detach your feature instead of unsupressing it, but unfortunately I don't know how to get that done via API.
There is a Detach/Attach method on the Model, but as all features share the same model, I don't see how this would work...
Even after manually detaching a cutout from a protrusion, the parent of both features pointed to the same model.
In fact I discovered that there is an error in my part when I create an Extruded protrusion. The feature has a red exclamation point before it as you can see in the picture.
I'm trying to resolve but I can't figure it out. I'm sending a piece of code. Could you please try to see where is my mistake? Thanks in advance!
// Conecta a Instância app = (SolidEdgeFramework.Application)Marshal.GetActiveObject("SolidEdge.Application"); // Desliga os Alertas. Weldment irá disparar alertas app.DisplayAlerts = false; // Referência dos Documentos docs = app.Documents; // Adicionamento de Part para reutilização part = (SolidEdgePart.PartDocument)docs.Open(_caminhoSketch); sketches = part.Sketches; sketch = sketches.Item(1); profile = sketch.Profile; profile.Visible = false; aProfiles = Array.CreateInstance(typeof(SolidEdgePart.Profile), 1); aProfiles.SetValue(profile, 0);
// Get a reference to the models collection models = part.Models; // Create the extended protrusion. model = models.AddFiniteExtrudedProtrusion(aProfiles.Length, ref aProfiles, SolidEdgePart.FeaturePropertyConstants.igLeft, _altura / 1000.0, Missing.Value, Missing.Value, Missing.Value, Missing.Value);
I've got an "U" like shape sketch which I want to extrude, but with the code above it's only working when the sketch is in Syncronous mode.
Here follows the desired result, obtained in syncronous mode:
The following code should work on either a synchronous or ordered sketch. For test purposes, I created a file with a single ordered U-shape sketch and a file with a single synchronous U-shape sketch. Running the code below on both files worked for me. It is important that you explicitly switch to ordered mode, if you want to get an ordered extruded protrusion:
//---------------------------------------------------------------------- // PAR: Create an ordered protrusion from an ordered/synchronous sketch //---------------------------------------------------------------------- PartDocument pDoc= (PartDocument) pSEApp.ActiveDocument; // Transition to ordered mode pDoc.ModelingMode = ModelingModeConstants.seModelingModeOrdered; Sketchs pSketches = pDoc.Sketches; Profile pProf = (Profile) pSketches.Item(1).Profile; pProf.Visible = false; Array profs = Array.CreateInstance(typeof(Profile), 1); profs.SetValue(pProf, 0); object optArg = Type.Missing; pDoc.Models.AddFiniteExtrudedProtrusion(1, ref profs, FeaturePropertyConstants.igLeft, 0.04, optArg, optArg, optArg, optArg);
There is something wrong with my U-shape sketch. I tryied your code and it didn't work. So I sketched a single rectangle and it worked.
I'm investigating it at this moment and when I have news I'll post here.
When you have some time, please take a look at my sketch. Could you try to extrude it to see if you'll have any problems?
It seems to be something related to the rounded corners of my sketch.
I sketched another U-shape with common borders and it works fine.
I guess it's not working because of the ordered nature of the part. I think I'll have to do one thing after the other. First extrude and then round the edges programatically. Maybe it's a concept problem.
Seems to be an API problem with the fillets in the profile.
I tried a simple triangle with none and with one fillet. Both profiles could be extruded via API, but as soon as I add a second fillet, the extrusion fails!!
The same happend to me with a simple rectangle. When I added the second fillet the extrusion failed.
I'll ask the support team in my company for the credentials so that I can open an IR. I'll try to add the fillets programatically.