Exemplo n.º 1
0
        private void CreateInvLayout()
        {
            CreateLayoutPartFile();

            Inventor.AssemblyComponentDefinition componentDefinition = InventorServices.Persistence.PersistenceManager.ActiveAssemblyDoc.ComponentDefinition;
            TransformationMatrix = InventorApplication.TransientGeometry.CreateMatrix();
            ComponentOccurrence  componentOccurrence = componentDefinition.Occurrences.Add(LayoutPartPath, TransformationMatrix);
            ComponentOccurrences occurrences         = componentDefinition.Occurrences;

            //TODO This is janky.  Don't need to assume that we are starting in an empty assembly file.
            ComponentOccurrence     layoutOccurrence          = occurrences[1];
            PartComponentDefinition layoutComponentDefinition = (PartComponentDefinition)layoutOccurrence.Definition;

            for (int i = 0; i < ModulePoints.Count; i++)
            {
                WorkPoint workPoint = layoutComponentDefinition.WorkPoints.AddFixed(ModulePoints[i], false);
                workPoint.Grounded = true;
                workPoint.Visible  = false;
                //Inventor's API documentation is so bad!
                object workPointProxyObject;
                layoutOccurrence.CreateGeometryProxy(workPoint, out workPointProxyObject);
                LayoutWorkPointProxies.Add((WorkPointProxy)workPointProxyObject);
                LayoutWorkPoints.Add(workPoint);
            }

            LayoutWorkPlane          = layoutComponentDefinition.WorkPlanes.AddByThreePoints(layoutWorkPoints[0], layoutWorkPoints[1], layoutWorkPoints[2]);
            LayoutWorkPlane.Grounded = true;
            LayoutWorkPlane.Visible  = false;
            object wPlaneProxyObject;

            layoutOccurrence.CreateGeometryProxy(LayoutWorkPlane, out wPlaneProxyObject);
            ModuleWorkPlaneProxyAssembly = (WorkPlaneProxy)wPlaneProxyObject;
        }
Exemplo n.º 2
0
        /// <summary>
        /// We are creating a new assembly, with new unique subassemblies derived from the template assembly.
        /// The first thing we need in this new assembly is a "layout part".  This will be the first thing we put
        /// in the assembly and it will contain all of the work points that we need to place and contstrain
        /// each module instance.
        /// </summary>
        ///
        private void CreateLayout(string destinationFolder)
        {
            //TODO: The next line is super brittle.  Need to finish writing out what expected behavior should be for responding to
            //Document activations/deactivations.  Right now InventorPersistenceManager.ActiveAssemblyDoc is being kept current, but that
            //may be bad.
            Inventor.AssemblyComponentDefinition componentDefinition = PersistenceManager.ActiveAssemblyDoc.ComponentDefinition;
            if (TransformationMatrix == null)
            {
                TransformationMatrix = PersistenceManager.InventorApplication.TransientGeometry.CreateMatrix();
            }
            //We know that there is a Layout.ipt file on the disc if we are here.
            //Try to bind to the ComponentOccurrence that corresponds to this file in
            //our assembly, otherwise place it, and SetObjectForTrace.
            layoutComponentDefinition = GetLayoutCompDef(componentDefinition);

            for (int i = 0; i < ModulesList.Count; i++)
            {
                //0 is reserved for top level assembly objects that require binding support.
                int moduleNumber = i + 1;
                ModulesList[i].PlaceWorkGeometryForContsraints(layoutComponentDefinition, LayoutOccurrence, moduleNumber);
            }
        }
Exemplo n.º 3
0
        private PartComponentDefinition GetLayoutCompDef(Inventor.AssemblyComponentDefinition componentDefinition)
        {
            ComponentOccurrence layoutOccurrence;

            if (_binder.GetObjectFromTrace <ComponentOccurrence>(out layoutOccurrence))
            {
                LayoutOccurrence = layoutOccurrence;
                PartComponentDefinition layoutComponentDefinition = (PartComponentDefinition)layoutOccurrence.Definition;
                AssemblyOccurrences = componentDefinition.Occurrences;
                return(layoutComponentDefinition);
            }

            else
            {
                layoutOccurrence = componentDefinition.Occurrences.Add(LayoutPartPath, TransformationMatrix);
                //This delegate should be part of the implementation of some construction dependency.  No need for
                //it to be in here.
                _binder.SetObjectForTrace <ComponentOccurrence>(layoutOccurrence, ModuleUtilities.ReferenceKeysSorter);
                LayoutOccurrence = layoutOccurrence;
                PartComponentDefinition layoutComponentDefinition = (PartComponentDefinition)layoutOccurrence.Definition;
                AssemblyOccurrences = componentDefinition.Occurrences;
                return(layoutComponentDefinition);
            }
        }
Exemplo n.º 4
0
 public static InvAssemblyComponentDefinition ByInvAssemblyComponentDefinition(Inventor.AssemblyComponentDefinition invAssemblyComponentDefinition)
 {
     return(new InvAssemblyComponentDefinition(invAssemblyComponentDefinition));
 }
Exemplo n.º 5
0
 private InvAssemblyComponentDefinition(Inventor.AssemblyComponentDefinition invAssemblyComponentDefinition)
 {
     InternalAssemblyComponentDefinition = invAssemblyComponentDefinition;
 }