.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

change the colorindex of an extruded region

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
Anonymous
713 Views, 6 Replies

change the colorindex of an extruded region

Hi,

I created a plate and later removed the hole to form an arc in the plate(attached image). However the boolean operation(boolsubstract) or the regions created is generating an arc with white colour, where as my remaining profile is red ( in program referred as colorindex CONTOUR = 0). I would like to change the arc color to red to make the profile look uniform. can someone please help me.

Thank you very much

 

 

My coding for creating region of the arc and boolean operation

 

 

// create solid of the arc
curves.Clear();
Circle arc = new Circle();
arc.Center = new Point3d(plate.L1 / 2.0, plate.L6, -plate.t);
arc.Diameter = plate.L2;
arc.ColorIndex = plate.nColor[CONTOUR];
curves.Add(arc);

// create the region from the curves
regions = Region.CreateFromCurves(curves);
holeSolid.Extrude((Region)regions[0], 3.0 * plate.t, 0);
holeSolid.ColorIndex = plate.nColor[CONTOUR];

// substract the hole solid from the rectangle
plateSolid.BooleanOperation(BooleanOperationType.BoolSubtract, holeSolid);

 

 

3DO.JPG

Tags (1)
6 REPLIES 6
Message 2 of 7
moogalm
in reply to: Anonymous

Can you please share the full reproducible code sample, I can have test it at my end..

Also try running CleanBody API, check if the unsupported contours are wiped off, you will get only solid.

Message 3 of 7
Anonymous
in reply to: moogalm

Hi Madhukar! I have attached the zip file of the complete program. I will be really delighted if you can send any links related to know more about CleanBody API. 

Thank you very much

Message 4 of 7
moogalm
in reply to: Anonymous

Thanks for your project, I'm not able to compile it as it reburies some Log file, which I don't see in the attachment.

 

From my understanding I have tried a written a sample code of create extrude solid from database residents arc and pline.

Attached drawing file and sample code, I don't see any discrepancy, when you create a solid from profile entity, created solid doesn't absorb profile data it only copies and creates solid. Hence changing color of Solid doesn't updates profiles like Arc and Pline here.

 

   [CommandMethod("TestMad")]
        public void updateSolidContourColor()
        {
            Document acDoc = Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;

            // Start a transaction
            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
            {
                // Request for objects to be selected in the drawing area
                PromptSelectionResult acSSPrompt = acDoc.Editor.GetSelection();

                // If the prompt status is OK, objects were selected
                if (acSSPrompt.Status == PromptStatus.OK)
                {
                    SelectionSet acSSet = acSSPrompt.Value;
                    DBObjectCollection curves = new DBObjectCollection();

                    // Step through the objects in the selection set
                    foreach (SelectedObject acSSObj in acSSet)
                    {
                        // Check to make sure a valid SelectedObject object was returned
                        if (acSSObj != null)
                        {
                            // Open the selected object for write
                            Curve acEnt = acTrans.GetObject(acSSObj.ObjectId, OpenMode.ForRead) as Curve;
                           
                            if (acEnt != null)
                            {
                                curves.Add(acEnt);
                                
                            }
                        }
                    }

                    DBObjectCollection regions = new DBObjectCollection();
                    /*Creating a region in memory*/
                    regions  = Region.CreateFromCurves(curves);

                    // Change the object's color to Green
                    // acEnt.ColorIndex = 3;
                    Solid3d extrude = new Solid3d();
                    extrude.RecordHistory = true;
                    SweepOptionsBuilder sob = new SweepOptionsBuilder();
                    Region r = regions[0] as Region;
                    extrude.CreateExtrudedSolid(r,r.Normal , sob.ToSweepOptions());
                    extrude.ColorIndex = 3;
                    /*Now remove profile contours.*/
                    //extrude.CleanBody();
                    BlockTableRecord btr = acTrans.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(acCurDb), OpenMode.ForWrite) as BlockTableRecord;
                    btr.AppendEntity(extrude);
                    acTrans.AddNewlyCreatedDBObject(extrude, true);


                    // Save the new object to the database
                    acTrans.Commit();
                }

                // Dispose of the transaction
            }

        }

solidContour.PNG

Message 5 of 7
Anonymous
in reply to: moogalm

Hi Madhukar!

Thanks a lot for your detailed clarification. I have one more question, how can we hide the profile data(arc and pline in your case) as we do in CATIA, since the profile is white in color and the solid is in different color. Why I am bothered is my profile looks like attached the image. I would make the appearance uniform, so that either the profile color is red or to be hidden.

Meanwhile can I know what is the error while executing the program, so that I can send the file once again, though I have attached the complete associated files in the same file.

 

Thank you!

Message 6 of 7
moogalm
in reply to: Anonymous

Hi,

 

Your code reads information from a log file [My mind though log file means a .TXT 😞  ], I dint find log in the attachment initially, I realized later  that there exits an excel file.

 

You can change the visibility of an Entity, set it to false.

 

Message 7 of 7
Anonymous
in reply to: moogalm

Thank you Madhukar!!

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report