Can this be done with iLogic? Plane creation based on number of points?

Can this be done with iLogic? Plane creation based on number of points?

chris
Advisor Advisor
211 Views
3 Replies
Message 1 of 4

Can this be done with iLogic? Plane creation based on number of points?

chris
Advisor
Advisor

Here's what I am trying to do, I've created a arc/curve. I've added a work point to the beginning and array'd that work point along the arc/curve, evenly, a user-defined number of times. Now I'd like to have a plane created "at each point" that is perpendicular to the arc/curve.

 

I can do this manually, but what I'm hoping iLogic can do is create or delete the planes based on the user-defined number of work points.

 

On top of that, can I also have a copied sketch profile/block then be added to those planes, based on the user-defined number of work points?

 

Bonus points if a rotation option can be added for each plane, or of a twist can equally be added based on the number of planes?

0 Likes
212 Views
3 Replies
Replies (3)
Message 2 of 4

chris
Advisor
Advisor

'm trying to mimic a portion of this: https://www.youtube.com/watch?v=QKXiBgtzOsY

 

0 Likes
Message 3 of 4

ryan.rittenhouse
Advocate
Advocate

I've done something similar to what you're hunting. You can grab your line and workpoint and then use AddByNormalToCurve to create your work plane. Since we don't have a way to flip the normal in iLogic, you may have to dance around which way the plane is facing.

 

I haven't done placing a sketch block on the plane, but I do play with iFeatures placed on an added plane and that has rotation built right in. You can define your PlaneInput as your new WorkPlane and feed in the rotation angle you'd like to use. 

 

I hope some of this helps.

If this solved your problem, or answered your question, please click Accept Solution.
0 Likes
Message 4 of 4

daltonNYAW9
Advocate
Advocate

Tried messing around with this yesterday. I first created a sketch line and patterned points along it. Then created the sketch + block for the first point. Seems to work fine. Connecting the sketches w/ a 3d sketch could be challenging.

Sub Main
	' Get the transaction manager from the application
	Dim oTxnMgr As TransactionManager
	oTxnMgr = ThisApplication.TransactionManager

	' Start a regular transaction
	Dim oTxn As Transaction
	oTxn = oTxnMgr.StartTransaction(ThisDoc.Document, "undo")

	Dim oPDoc As PartDocument = ThisApplication.ActiveDocument
	Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
	Dim oPoint2d As Point2d = ThisApplication.TransientGeometry.CreatePoint2d()
	Dim startRotation As Double = 0
	Dim endRotation As Double = 222

	For i = 4 To oPDef.WorkPlanes.Count
		Dim oWorkPlane As WorkPlane = oPDef.WorkPlanes(i)
		'oWorkPlane.SetByNormalToCurve(oPDef.Sketches3D.Item(1), oPDef.WorkPoints.Item(i - 2))
		'oWorkPlane.SetByNormalToCurve(oPDef.Sketches3D.Item(1).SketchEntities3D(1), oPDef.WorkPoints.Item(i - 2))
		RotateBlock(oPDef.Sketches.Item(i - 3), i - 3, startRotation, endRotation)
	Next

	For i = oPDef.WorkPlanes.Count - 3 To oPDef.WorkPoints.Count - 2
		Dim oWorkPlane As WorkPlane = oPDef.WorkPlanes.AddByNormalToCurve(oPDef.Sketches3D.Item(1).SketchEntities3D(1), oPDef.WorkPoints(i + 2))
		Dim oSketch2 As PlanarSketch = oPDef.Sketches.Add(oWorkPlane, False)
		oSketch2.SketchBlocks.AddByDefinition(oPDef.SketchBlockDefinitions(1), oPoint2d)
		Dim oSketchEntity As SketchEntity = oSketch2.AddByProjectingEntity(oPDef.WorkPoints(i + 2))
		Dim oInsSpt As SketchPoint = oSketch2.SketchBlocks(1).GetObject(oSketch2.SketchBlocks(1).Definition.InsertionPoint)
		oSketch2.GeometricConstraints.AddCoincident(oInsSpt, oSketchEntity)
		RotateBlock(oPDef.Sketches.Item(i + 1), i + 2, startRotation, endRotation)
	Next
	ThisDoc.Document.Rebuild
	oTxn.End
End Sub

Sub RotateBlock(oSketch As PlanarSketch, SketchNumb As Integer, startRotation As Double, endRotation As Double)
	'https://forums.autodesk.com/t5/inventor-programming-ilogic/rotate-sketchblock-in-sketch/td-p/9684760
	Dim oSBlock As SketchBlock = oSketch.SketchBlocks(1)
	Dim oOrgMatrix As Matrix2d = oSBlock.Transformation.Copy
	Dim oOPoint As Point2d
	Dim oXAxis, oYAxis As Vector2d
	oOrgMatrix.GetCoordinateSystem(oOPoint, oXAxis, oYAxis)
	Dim oAngle As Double = (endRotation - startRotation) * (SketchNumb / (oSketch.Parent.WorkPoints.Count - 1)) Mod 360
	Dim oRad As Double = (oAngle / 180) * PI
	oOrgMatrix.SetToRotation(oRad, oOPoint)
	oSBlock.Transformation = oOrgMatrix
End Sub

 

0 Likes