Reply

Changing a part's coordinate system (c++/c#)

[ Edited ]

Hello everyone,

 

I searched the net but could not find a simple solution to my problem and I would appreciate your suggestions.

 

I have many assemblies which were created in a top-down manner, i.e. all the parts were created from the assembly and therefore every part lays in a different and sloped coordinate system.

 

I need to rotate all the parts in every assembly so that the parts will lay on one of the 3 main planes - XY, YZ, ZX so that I can analyze them in an outer program.

There's an option to do this manually in the SE UI (Edit definitions -> Extrude-sketch step -> choose coincident type of plane and select one of the wanted planes from the list base reference planes (like 'Top(xy)') in the list of features on the left) but it would take ages to convert all the parts manually.

 

Can you suggest an automated method that does not require reading the parts, recalculating the coordinates and building them again in a new document ?

 

Thanks !

 

Posted by: Guy G
Post date: 4/19/2012 3:39:05 AM

1 REPLY

Re: Changing a part's coordinate system (c++/c#)

[ Edited ]

I think I am getting closer.

Finally I found a way to access the ref-plane data (thanks to the .Net programmer's guide).

 

 

     SolidEdgeFramework.Application application = null;
            SolidEdgeFramework.Documents documents = null;
            SolidEdgeFramework.SolidEdgeDocument doc = 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;
            System.Array aProfiles = null;
            try
            {
                // Connect to a running instance of Solid Edge
                application = (SolidEdgeFramework.Application) Marshal.GetActiveObject("SolidEdge.Application");


                doc = (SolidEdgeFramework.SolidEdgeDocument)application.ActiveDocument;
                if (doc.Type != SolidEdgeFramework.DocumentTypeConstants.igPartDocument)
                {
                    throw new Exception(doc.FullName + " is not a part file.");
                }

                // Get a reference to the active document
                part = (SolidEdgePart.PartDocument) application.ActiveDocument;
                
                // Get a reference to the profile sets collection
                profileSets = part.ProfileSets;

                profileSet = profileSets.Item(1);
                // Get a reference to the profiles collection
                profiles = profileSet.Profiles;
                // Get a reference to the ref planes collection
                refplanes = part.RefPlanes;
                
               
                profile = profiles.Item(1);

                // setting the ref-plane to be XY
                profile.Plane = refplanes.Item(1);

 

From this skeleton a cleaner program can be built BUT this rotates only the first item.

If this is used on the other features, such as cut extrudes I think they will be flattened.

 

You'd have to implement a plane rotation arithmetic.... and so will I.... unless someone has a better solution.

 

Posted by: Guy G
Post date: 4/19/2012 6:23:52 AM