- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
So I want to place a parameter into a sketch that will be embossed. Here's the problem, I got the code to do what i want but it places the parameter as a string instead of a parameter (because i want it to automatically update if i change that parameter). Any help would be greatly appreciated! Thank You! I can code in both vb.net and c# so you can use whatever you prefer, but here is my code:
Dim oPart As PartDocument = invApp.ActiveDocument 'resetting part document
Dim oDoc As Document = invApp.ActiveDocument
Dim oComponentDefinition As ComponentDefinition = oPart.ComponentDefinition
Dim oFace As Face = invApp.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Pick a face")
Dim Sketch As PlanarSketch = oComponentDefinition.Sketches.Add(oFace, True)
Dim oTG As TransientGeometry
oTG = invApp.TransientGeometry
Dim oEdge As Edge
Dim oEdge2 As Edge
oEdge = invApp.CommandManager.Pick(SelectionFilterEnum.kPartEdgeMidpointFilter, "Pick Left Hand Edge")
oEdge2 = invApp.CommandManager.Pick(SelectionFilterEnum.kPartEdgeMidpointFilter, "Pick Bottom Edge")
Dim userParameters As UserParameters = oPart.ComponentDefinition.Parameters.UserParameters
Dim param As Parameter = userParameters.Item(1)
Dim oTextBox As Inventor.TextBox
oTextBox = Sketch.TextBoxes.AddFitted(oTG.CreatePoint2d((oEdge.PointOnEdge.X + oEdge2.PointOnEdge.X) / 2, (oEdge.PointOnEdge.Y + oEdge2.PointOnEdge.Y) / 2), param)
Dim oPaths As ObjectCollection
oPaths = invApp.TransientObjects.CreateObjectCollection
oPaths.Add(oTextBox)
Dim oProfile As Profile
oProfile = sketch.Profiles.AddForSolid(False, oPaths)
Dim oExtrudeDef As ExtrudeDefinition
oExtrudeDef = oComponentDefinition.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfile, Inventor.PartFeatureOperationEnum.kCutOperation)
Call oExtrudeDef.SetDistanceExtent(0.25, Inventor.PartFeatureExtentDirectionEnum.kNegativeExtentDirection)
Dim oExtrude As ExtrudeFeature
oExtrude = oComponentDefinition.Features.ExtrudeFeatures.Add(oExtrudeDef)
Solved! Go to Solution.