Hello all!
Would anyone know the way to create say, a workaxis between two parts in an assembly, making the part adaptive.
I have tried converting the geometry to proxy objects, but that didn't work, and then I tried to make geometry proxies of the geometry proxies from the 2nd panel.
I am trying to use "WorkAxis.AddByNormalToSurface" but it just infinitely gives me "Parameter is incorrect". Any help is appreciated!
Solved! Go to Solution.
Solved by C_Haines_ENG. Go to Solution.
Ill attach the trial code I'm using:
Dim oAsm As AssemblyDocument = ThisDoc.Document ' THE FACE IS THE OBJECT GETTING THE AXIS. Dim oFace As FaceProxy = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFacePlanarFilter, "Face") ' THE WORKPOINT FROM THE OTHER PART.
Dim oWP As WorkPointProxy = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kWorkPointFilter, "WorkPoint") Dim oComp As ComponentOccurrence = oFace.ContainingOccurrence Dim oCompDef As PartComponentDefinition = oComp.Definition oCompDef.WorkAxes.AddByNormalToSurface(oFace, oWP)
This just doesn't work with proxy objects. I don't know what secret its looking for, but its not well documented anywhere.
Hi @C_Haines_ENG. I'm on my way out for the day right now, but I am not sure that it will be possible to do it the way you want it to be (adaptive). Normally adaptive stuff requires 'projecting' geometry that exists in assembly space, into the definition of the part, while the component is in edit mode within the assembly. The 'real' geometry exists only within the definition of two different parts. The 'proxy' of each piece of geometry only exists in the context (3D coordinate model space) of the assembly. But you want to create geometry within one of the parts that matches the 'proxy' geometry in the assembly. Normally we would need to 'transform' the transient mathematical data defining the 'proxy' geometry, from the assembly's 'model space' into the part's 'model space', using a Matrix. Then use the 'transformed' version of that data to create the wanted geometry within the part's model space. It has to do with the location and orientation of that geometry in reference to the two component occurrences in assembly space. And I hope both occurrences are 'top level' ones, or else you may need multiple 'proxy' steps. But when using the 'Pick' function in an assembly, you always get a reference to the 'top level' proxy objects.
Wesley Crihfield
(Not an Autodesk Employee)
I'm slugging through it after realizing that Inventor actually creates these by creating a ".AddFixed" Axis and then constrains it to other geometry afterwards.
I'm just working through the transform Matrixes but I should get there eventually.
SLAMMED right into the wall, looks like it being a "Fixed" axis might be entirely irrelevant. I cant make it adaptive until I define it two another part.
I should note that this is perfectly achievable if you want to do it manually. Just have two parts in an assembly, double click on one to open it within the Assembly document, and then you can create adaptive geometry from part to part.
I cant even figure out how to place an axis while INSIDE the part file if I don't use fixed. I could very much so use some help here. I tried grabbing the NativeObject of the selections but even then, doesnt count. the "AddByNormalToSurface" which is what I am doing when placing it manually seems to require a "Surface" object which doesn't include faces, but it does work with WorkPlanes?
I'm still sort of set that it is a "Fixed" Axis which is then Constrained but for some reason doing that myself doesn't allow for Adaptability.
Okay I've got it working, and many lessons were had.
You CANNOT use a "Fixed" axis as it will make it impossible to unground and therefore impossible to make adaptive. You can use any other method, but 20% of them just don't work.
Every argument in the creation must be a native object to that part, as in a workpoint, sketchpoint, plane. Something physical.
You then after the fact toggle its Adaptivity, and then must constrain it so that it follows another object on the other part. You can only do this in the 1st level assembly. So if you have an assembly within an assembly it will not work.
See the code below:
Dim oAsm As AssemblyDocument = ThisDoc.Document Dim oPartMain As ComponentOccurrence Dim oPartRef As ComponentOccurrence ' SELECT MAIN AND REFERENCE PART oPartMain = ThisApplication.CommandManager.Pick(kAssemblyOccurrenceFilter, "Select Part To Have Axis") oPartRef = ThisApplication.CommandManager.Pick(kAssemblyOccurrenceFilter, "Select Part To Reference") 'YOU MUST MAKE THE PART ADAPTIVE oPartMain.Adaptive = True ' DEFINE COMPONENT DEFINITIONS Dim oMainDef As PartComponentDefinition = oPartMain.Definition Dim oRefDef As PartComponentDefinition = oPartRef.Definition Dim oRefPoint As WorkPoint = oRefDef.WorkPoints.Item(1) ' GET THE ORIGIN POINT OF THE REFERENCED PART. ' CREATE WORKAXIS IN THE MAIN PART WITH THE FIRST WORKPLANE, AND FIRST WORKPOINT (THESE MUST BE PHYSCIAL OBJECTS). Dim oWorkAxis As WorkAxis = oMainDef.WorkAxes.AddByNormalToSurface(oMainDef.WorkPlanes.Item(1), oMainDef.WorkPoints.Item(1)) oWorkAxis.AutoResize = True ' ENABLE AUTORESIZE, LOOKS BETTER oWorkAxis.Adaptive = True ' ENABLE ADAPTIVITY - THIS ALLOWS THE AXIS TO BE CONSTRAINED ' CREATE GEOMETRY PROXIES FOR THE OBJECTS SO THEY CAN BE REFERENCED BY THE ASSEMBLY oPartMain.CreateGeometryProxy(oWorkAxis, oAxisProxy) oPartRef.CreateGeometryProxy(oRefPoint, oPointProxy) ' ADD MATE CONSTRAINT oAsm.ComponentDefinition.Constraints.AddMateConstraint(oAxisProxy, oPointProxy, 0)
Hi @C_Haines_ENG. I'm glad you were able to achieve what you were wanting to achieve. Interesting result, but not what I was expecting, based on the first few posts in this topic.
Instead of 'creating' a new WorkAxis that was automatically 'adaptive' by definition (because of how it was created/defined), you just created a normal WorkAxis using internal/native inputs, and changed its adaptive setting to True (with nothing 'driving' its adaptiveness). Then only placed an assembly constraint between the two normal proxy objects in the assembly. Normally, an 'adaptive' feature will 'change' as the geometry within the assembly that it is associated with changes, but I do not think that is the case in this situation. Nothing we do in the assembly will change that WorkAxis within the part. With the 'main' component stationary (or fully constrained), and only that one new constraint effecting the 'other' component, I can drag the 'other' component all around in the assembly, and nothing effects or changes the WorkAxis within the 'main' part.
I was not sure which part you were wanting to 'Pick' the 'face' in, and which one you wanted to 'Pick' the point in, just based on the previous code and comments, but I did attempt to write a code solution for you yesterday. However, we had a sudden power failure yesterday while I was working on that, which shut everything down, then we got sent home for the day. I'm still catching up this morning, but my thoughts yesterday were to somehow project/transfer the proxy geometry from the 'other' component in assembly space into the 'main' part, so that it would have some actual geometry in it to base the WorkAxis on. Maybe something like a sketch. I have projected assembly geometry into part sketches by code several times before, so that process sounded like one possibility. That would give us the point geometry in the 'main' part, that we could use directly in our method for adding the new WrokAxis in that part. To do that, first get a reference to the point proxy from the 'other' part, then enter into 'edit mode' of the 'main' part's component in the assembly, then create a new sketch in the 'main' part, then project the point proxy into that sketch. Then you can use that projected sketch point as the point in your WorkAxis creation method. That sketch should then already be 'adaptive' because it contains the geometry which was projected from assembly space. Not sure if the WorkAxis would also automatically be adaptive, since it is based on that adaptive sketch geometry, but it should 'effectively' be adaptive either way.
Wesley Crihfield
(Not an Autodesk Employee)
I may or may not have forgotten the ever crucial part of also making the PART adaptive, that's why it wasn't working for you.
Dim oAsm As AssemblyDocument = ThisDoc.Document Dim oPartMain As ComponentOccurrence Dim oPartRef As ComponentOccurrence ' SELECT MAIN AND REFERENCE PART oPartMain = ThisApplication.CommandManager.Pick(kAssemblyOccurrenceFilter, "Select Part To Have Axis") oPartRef = ThisApplication.CommandManager.Pick(kAssemblyOccurrenceFilter, "Select Part To Reference") 'YOU MUST MAKE THE PART ADAPTIVE oPartMain.Adaptive = True ' DEFINE COMPONENT DEFINITIONS Dim oMainDef As PartComponentDefinition = oPartMain.Definition Dim oRefDef As PartComponentDefinition = oPartRef.Definition Dim oRefPoint As WorkPoint = oRefDef.WorkPoints.Item(1) ' GET THE ORIGIN POINT OF THE REFERENCED PART. ' CREATE WORKAXIS IN THE MAIN PART WITH THE FIRST WORKPLANE, AND FIRST WORKPOINT (THESE MUST BE PHYSCIAL OBJECTS). Dim oWorkAxis As WorkAxis = oMainDef.WorkAxes.AddByNormalToSurface(oMainDef.WorkPlanes.Item(1), oMainDef.WorkPoints.Item(1)) oWorkAxis.AutoResize = True ' ENABLE AUTORESIZE, LOOKS BETTER oWorkAxis.Adaptive = True ' ENABLE ADAPTIVITY - THIS ALLOWS THE AXIS TO BE CONSTRAINED ' CREATE GEOMETRY PROXIES FOR THE OBJECTS SO THEY CAN BE REFERENCED BY THE ASSEMBLY oPartMain.CreateGeometryProxy(oWorkAxis, oAxisProxy) oPartRef.CreateGeometryProxy(oRefPoint, oPointProxy) ' ADD MATE CONSTRAINT oAsm.ComponentDefinition.Constraints.AddMateConstraint(oAxisProxy, oPointProxy, 0)
You also cant drag them once they are marked as adaptive, they can only be moved with constraints.
I've attached an example assembly file if you're curious, its got the rule added and a form to slide the part around.
OK. That did it. I could not use your ZIP file, due to restrictions where I work, but I fully constrained both parts in a local test assembly, with simple planar offsets from the assembly origin planes, a little differently from each other. Then applied your modified code to them. Then changed the constraint offsets in the assembly, and saw that it also changed the location of the WorkAxis in the part. And no special 'projected' geometry node in the part that can be seen in the model browser tree either. Nice.
Wesley Crihfield
(Not an Autodesk Employee)
Can't find what you're looking for? Ask the community or share your knowledge.