Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Add three central planes to selected parts

6 REPLIES 6
Reply
Message 1 of 7
kresh.bell
213 Views, 6 Replies

Add three central planes to selected parts

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.

 

2022-12-11_08-39-57 04.jpg

6 REPLIES 6
Message 2 of 7
A.Acheson
in reply to: kresh.bell

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. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 3 of 7
JelteDeJong
in reply to: kresh.bell

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.

EESignature


Blog: hjalte.nl - github.com

Message 4 of 7
A.Acheson
in reply to: kresh.bell

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)

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 5 of 7
kresh.bell
in reply to: A.Acheson

"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

 

2022-12-12_06-37-48 05.jpg

Message 6 of 7
A.Acheson
in reply to: kresh.bell

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. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 7 of 7
kresh.bell
in reply to: A.Acheson

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.

Post to forums  

Technology Administrators


Autodesk Design & Make Report