Color in solid edge

Experimenter
Experimenter

Hello everyone: Smileyhappy:

I have square constructed with c # in solid.
But I have now colored
can someone help me. does anyone have idea how I can square colored with C sharp.

my

code looks like this
/ / Draw the base profiles

lines2d.AddBy2Points (A, C, A, B) ;/ / Line lines2d.AddBy2Points (A, B, D, B); lines2d.AddBy2Points (D, B, D, C); lines2d.AddBy2Points (D, C, A, C);

/ / Define relations among the Line objects to make the profiles closed relations2d = (SolidEdgeFrameworkSupport.Relations2d) profile.Relations2d; relation2d = relations2d.AddKeypoint (lines2d.Item (1), (int) KeypointIndexConstants.igLineEnd, lines2d.Item (2), (int) KeypointIndexConstants.igLineStart, true); relation2d = relations2d.AddKeypoint (lines2d.Item (2), (int) KeypointIndexConstants.igLineEnd, lines2d.Item (3), (int) KeypointIndexConstants.igLineStart, true); relation2d = relations2d.AddKeypoint (lines2d.Item (3), (int) KeypointIndexConstants.igLineEnd, lines2d.Item (4), (int) KeypointIndexConstants.igLineStart, true); relation2d = relations2d.AddKeypoint (lines2d.Item (4), (int) KeypointIndexConstants.igLineEnd, lines2d.Item (1), (int) KeypointIndexConstants.igLineStart, true);

Thanks

4 REPLIES

Re: Color in solid edge

Phenom
Phenom

Hello Karapara,

 

Here is one way:

 

lines2d.Item(1).Style.LinearColor = 16711680 // for Blue

 

Also I'd suggest using 'Insert Code' for the purpose.

 

Untitled.png

 

~Regards,

Re: Color in solid edge

Experimenter
Experimenter

hallo Tushar

Thanks for the helpful reply

but I want to change the square surface colors and not just the perimeter. maybe you have idea

 Thanks a lot

Re: Color in solid edge

Phenom
Phenom

Karapara,

 

Your term 'square surface' leads to several possibilities -

1. Are you creating a boundary patch using the line and change its color.

2. Extruding the square to a solid block whose surface colors you want to change.

3. You want to fill a solid pattern inside the square and change its color.

 

The code you posted has nothing inside the limits of the square - its a void and cannot be colored.

Can you kindly post the complete working code that creates the surface.

 

Regards,

 

Re: Color in solid edge

Experimenter
Experimenter


2 and 3 the possibility ...
First I want a solid fill pattern in the square and change their color.
I want to an extruded part of the (already konstruriert with solidedge) failed with c #
my code is not quite right and not complet

using SolidEdgeConstants;
using System;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Drawing;
using System.Threading;
namespace MyMacro
{
    class Program
    {
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application application = null;
            SolidEdgeFramework.Documents documents = null;
            SolidEdgePart.PartDocument part = null;
            SolidEdgePart.ProfileSets profileSets = null;
            SolidEdgePart.ProfileSet profileSet = null;
            SolidEdgePart.Profiles profiles = null;
            SolidEdgePart.Profile profile = null;
            SolidEdgePart.RefPlanes refplanes = null;
            SolidEdgeFrameworkSupport.Relations2d relations2d = null;
            SolidEdgeFrameworkSupport.Relation2d relation2d = null;
            SolidEdgeFrameworkSupport.Lines2d lines2d = null;
            SolidEdgeFrameworkSupport.Line2d line2d = null;
            SolidEdgePart.Models models = null;
            SolidEdgePart.Model model = null;
            SolidEdgeAssembly.AssemblyDocument assembly = null;
            SolidEdgeAssembly.Occurrences occurrences = null;
            SolidEdgeAssembly.Occurrence occurrence = null;
            System.Array aProfiles = null;
            try
            {
                // Connect to a running instance of Solid Edge 
                application = (SolidEdgeFramework.Application)
                Marshal.GetActiveObject("SolidEdge.Application");
                // Get a reference to the documents collection 
                documents = application.Documents;
                // Create a new part document 
                part = (SolidEdgePart.PartDocument)
                documents.Add("SolidEdge.PartDocument", Missing.Value);
                // Get a reference to the profile sets collection 
                profileSets = part.ProfileSets;
                // Add a new profile set 
                profileSet = profileSets.Add();
                // aDD a new farbe 
                
                // Get a reference to the profiles collection 
                profiles = profileSet.Profiles;
                // Get a reference to the ref planes collection 
                refplanes = part.RefPlanes;
                // Add a new profile 
                profile = profiles.Add(refplanes.Item(3));
                // Get a reference to the lines2d collection 
                lines2d = profile.Lines2d;
                //parameter
                double A = -1.5;
                double B = -2;
                double C = 6;
                double D = -4;


                // Draw the Base Profile 
                lines2d.AddBy2Points(A, C, A, B);// Line 
                lines2d.AddBy2Points(A, B, D, B);
                lines2d.AddBy2Points(D, B, D, C);
                lines2d.AddBy2Points(D, C, A, C);
                // Define Relations among the Line objects to make the Profile closed 
                relations2d = (SolidEdgeFrameworkSupport.Relations2d)
                profile.Relations2d;
                relation2d = relations2d.AddKeypoint(lines2d.Item(1), (int)KeypointIndexConstants.igLineEnd, lines2d.Item(2), (int)KeypointIndexConstants.igLineStart, true);
                relation2d = relations2d.AddKeypoint(lines2d.Item(2), (int)KeypointIndexConstants.igLineEnd, lines2d.Item(3), (int)KeypointIndexConstants.igLineStart, true);
                relation2d = relations2d.AddKeypoint(lines2d.Item(3), (int)KeypointIndexConstants.igLineEnd, lines2d.Item(4), (int)KeypointIndexConstants.igLineStart, true);
                relation2d = relations2d.AddKeypoint(lines2d.Item(4), (int)KeypointIndexConstants.igLineEnd, lines2d.Item(1), (int)KeypointIndexConstants.igLineStart, true);
                lines2d.Item(1).Style.LinearColor = 65280;// grün
                lines2d.Item(2).Style.LinearColor = 65535;// Gleb
                lines2d.Item(3).Style.LinearColor = 16711935;// Blau
                lines2d.Item(4).Style.LinearColor = 255;// Rot
 
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                if (model != null)
                {
                    Marshal.ReleaseComObject(model);
                    model = null;
                }
                if (models != null)
                {
                    Marshal.ReleaseComObject(models);
                    models = null;
                }
                if (line2d != null)
                {
                    Marshal.ReleaseComObject(line2d);
                    line2d = null;
                }
                if (lines2d != null)
                {
                    Marshal.ReleaseComObject(lines2d);
                    lines2d = null;
                }
                if (relation2d != null)
                {
                    Marshal.ReleaseComObject(relation2d);
                    relation2d = null;
                }
                if (relations2d != null)
                {
                    Marshal.ReleaseComObject(relations2d);
                    relations2d = null;
                }
                if (refplanes != null)
                {
                    Marshal.ReleaseComObject(refplanes);
                    refplanes = null;
                }
                if (profile != null)
                {
                    Marshal.ReleaseComObject(profile);
                    profile = null;
                }
                if (profileSet != null)
                {
                    Marshal.ReleaseComObject(profileSet);
                    profileSet = null;
                }
                if (profileSets != null)
                {
                    Marshal.ReleaseComObject(profileSets);
                    profileSets = null;
                }
                if (part != null)
                {
                    Marshal.ReleaseComObject(part);
                    part = null;
                }
                if (documents != null)
                {
                    Marshal.ReleaseComObject(documents);
                    documents = null;
                }
                if (application != null)
                {
                    Marshal.ReleaseComObject(application);
                    application = null;
                }
            }
        }
    }
}