Hi,
is it possible to make an iLogic that would add three central planes to the selected parts (for all selected parts, but if it will work one by one that will be great) in the assembly environment?
Now I use Parallel to Plane through Point three, times for each part.
Would this operation be best done in the parts themselves? Perhaps by modelling them around the center point and using the XY,XZ,YZ planes. Are the parts created using place components? If this is the case they won't have work planes that are centered around the solid body and I could understand the reason. The reason being is any plane created may not update if the position of the body is changed.
You could try something like his:
Dim doc As AssemblyDocument = ThisDoc.Document
Dim occ As ComponentOccurrence = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select a part")
Dim refDoc As Document = occ.ReferencedDocumentDescriptor.ReferencedDocument
For Each workplane As WorkPlane In refDoc.ComponentDefinition.WorkPlanes
If (Not WorkPlane.IsCoordinateSystemElement) Then Continue For
Dim workPlaneProxy As WorkPlaneProxy
occ.CreateGeometryProxy(WorkPlane, workPlaneProxy)
Dim oOriginPnt As Point
Dim oXaxis As UnitVector
Dim oYaxis As UnitVector
workPlaneProxy.GetPosition(oOriginPnt, oXaxis, oYaxis)
Dim newWorkPlane = doc.ComponentDefinition.WorkPlanes.AddFixed(oOriginPnt, oXaxis, oYaxis)
newWorkPlane.Name = String.Format("{0}: {1}", occ.Name, WorkPlane.Name)
Next
Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Blog: hjalte.nl - github.com
Here is an attempt to recreate that functionality. The Workplane creation on point method is not supported by the API for assemblies, so you need to create a workplane and then try and constraint to the center of the edge. That skill is eluding me at this time so the below is a partial automation. It just places a workpoint in the center of the occurrence then creates workplanes around this point. However it will not update the workplane position if the occurrence is moved. This is because the planes just exist in space and are not connected to the occurrence.
Dim oAssyDoc As AssemblyDocument = ThisDoc.Document
Dim oAsmDef As AssemblyComponentDefinition = oAssyDoc.ComponentDefinition
'Pick occurrence
Dim oOcc As ComponentOccurrence = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select Occurence")
Dim oOccDef As PartComponentDefinition = oOcc.Definition
'Get center of part relating to Part 0,0,0
Dim CtrX As Double = (oOccDef.RangeBox.MaxPoint.X - oOccDef.RangeBox.MinPoint.X)/2
Dim CtrY As Double = (oOccDef.RangeBox.MaxPoint.Y - oOccDef.RangeBox.MinPoint.Y)/2
Dim CtrZ As Double = (oOccDef.RangeBox.MaxPoint.Z - oOccDef.RangeBox.MinPoint.Z)/2
'Get center of part in relation to Assembly 0,0,0
Dim oOccCtrX As Double = oOccDef.RangeBox.MinPoint.X + CtrX
Dim oOccCtrY As Double = oOccDef.RangeBox.MinPoint.Y + CtrY
Dim oOccCtrZ As Double = oOccDef.RangeBox.MinPoint.Z + CtrZ
Dim oTrans As TransientGeometry = ThisApplication.TransientGeometry
Dim oPnt As Point = oTrans.CreatePoint(oOccCtrX, oOccCtrY, oOccCtrZ)
Dim oWPt1 As WorkPoint = oAsmDef.WorkPoints.AddFixed(oPnt, False)
oXaxis1 = ThisApplication.TransientGeometry.CreateUnitVector(1, 0, 0)'x has a direction
oYaxis1 = ThisApplication.TransientGeometry.CreateUnitVector(0, 1, 0)'y has a direction
Dim XYPlane As WorkPlane = oAsmDef.WorkPlanes.AddFixed(oPnt, oXaxis1, oYaxis1)
oXaxis2 = ThisApplication.TransientGeometry.CreateUnitVector(1, 0, 0)'x has a direction
oYaxis2 = ThisApplication.TransientGeometry.CreateUnitVector(0, 0, 1)'z has a direction
Dim XZPlane As WorkPlane = oAsmDef.WorkPlanes.AddFixed(oPnt, oXaxis2, oYaxis2)
oXaxis3 = ThisApplication.TransientGeometry.CreateUnitVector(0, 1, 0)'y has a direction
oYaxis3 = ThisApplication.TransientGeometry.CreateUnitVector(0, 0, 1)'z has a direction
Dim YZPlane As WorkPlane = oAsmDef.WorkPlanes.AddFixed(oPnt, oXaxis3, oYaxis3)
"However, it will not update the workplane position if the occurrence is moved" -
that it is a key problem, it is exactly what I need
Would it help if I had custom iProperties for each part?
thickness = DEB
length = DUZ
width = SIR
Unfortunately not the range box method is allready getting those sizes. What is needed is to select the correct face x3 (automatically) picking would be just as time consuming as it is manually and constrain the created workplanes to those proxy faces offset half the length,width,thickness.
What would help a lot is if could get planes that are half the thickness, especially if there was an option to select multiple parts (one surface) and then iLogic create a plane that is half the thickness for all the selected parts
Can't find what you're looking for? Ask the community or share your knowledge.