Custom feature with user interaction

Custom feature with user interaction

psaarloos
Collaborator Collaborator
417 Views
3 Replies
Message 1 of 4

Custom feature with user interaction

psaarloos
Collaborator
Collaborator

Hi,

 

I am trying to create a custom feature which act a lot like the 'Hole' feature regarding the selection sequence.

 

The command is supposed to work on a sheet metal part. After starting the command the base face of the flat pattern (doc.ComponentDefinition.FlatPattern.BaseFace) should be highlighted in the 3D model.

 

The user then has to select a face. On this face a new sketch has to be created with sketch text placed on it. The user should be able to dimension the text to the edges of the face (this is pretty much the same as the hole feature).

 

I've been looking at the custom command sample in the SDK and some other materials on internet, but I am lost on how to implement the sketch creation, text placement and allowing the user to dimension it in a chained input sequence.

 

(would be nice to create this feature in a panel, but don't know how to create the interaction in a user control either)

 

Thanks in advance for your feedback.

 

 

Regards,
Pim Saarloos
Product Manager
If my post answers your question, please click the "Accept as Solution" button. Kudos are much appreciated!
0 Likes
418 Views
3 Replies
Replies (3)
Message 2 of 4

bradeneuropeArthur
Mentor
Mentor

Hoi Pim,

 

Would you like to do this in the model environment or in the flat pattern environment only?

 

Regards, 

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 4

CCarreiras
Mentor
Mentor

Hi!

 

Tried the "Punch tool" in sheet metal environment?

CCarreiras

EESignature

0 Likes
Message 4 of 4

JelteDeJong
Mentor
Mentor

hi @psaarloos,

I expect that you want to do this in a folded sheetmetal part. Hopefully this iLogic rule helps you with the first part of your question.

Dim doc As PartDocument = ThisDoc.Document
Dim oTg As TransientGeometry = ThisApplication.TransientGeometry

Dim highLight As HighlightSet
If (doc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}") Then
    highLight = doc.HighlightSets.Add()
    highLight.Color = ThisApplication.TransientObjects.CreateColor(0, 255, 0)
    Dim smDocDef As SheetMetalComponentDefinition = doc.ComponentDefinition
    For Each def As ASideDefinition In smDocDef.ASideDefinitions
        For Each aFace As Face In def.Faces
            highLight.AddItem(aFace)
        Next
    Next
End If

Dim sketch As PlanarSketch
Dim line1 As SketchLine
Dim line2 As SketchLine
Dim edge1 As Edge
Dim edge2 As Edge

' when you do this in a user control then you would not need ask this in a msgbox 
' but would it be an option on the user control
Dim res As Windows.Forms.DialogResult = Windows.Forms.MessageBox.Show(
    "do you want to seletc the lines?",
    "how to select.", Windows.Forms.MessageBoxButtons.YesNo)

Dim face As Face = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFacePlanarFilter, "select a face")
If (res = Windows.Forms.DialogResult.Yes) Then
    sketch = doc.ComponentDefinition.Sketches.Add(face, False)
    edge1 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartEdgeLinearFilter, "Select edge 1")
    edge2 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartEdgeLinearFilter, "Select edge 2")

    line1 = sketch.AddByProjectingEntity(edge1)
    line2 = sketch.AddByProjectingEntity(edge2)
Else
    sketch = doc.ComponentDefinition.Sketches.Add(face, True)
    line1 = sketch.SketchLines.Item(1)
    line2 = sketch.SketchLines.Item(2)
End If


Dim textBox As TextBox = sketch.TextBoxes.AddFitted(oTg.CreatePoint2d(1, 1), " ")
Dim dimension1 As DimensionConstraint = sketch.DimensionConstraints.AddOffset(
    line1, textBox.OriginSketchPoint, oTg.CreatePoint2d(0.5, 0.5), False)

Dim dimension2 As DimensionConstraint = sketch.DimensionConstraints.AddOffset(
    line2, textBox.OriginSketchPoint, oTg.CreatePoint2d(0.5, 0.5), False)

' this input boxes would normaly be textboxes on a user control 
Dim newText As String = InputBox("Set text:")
Dim newDim1 As String = InputBox("Set Dimension 1:")
Dim newDim2 As String = InputBox("Set Dimension 2:")

' here is how you would set the dimensions and text
textBox.Text = newText
dimension1.Parameter.Expression = newDim1
dimension2.Parameter.Expression = newDim2
doc.Update()

 Its not perfect. For example the text is not guaranteed to be on the face. When the text is created its placed near the origin not on the face.

For the second part of your question ("would be nice to create this feature in a panel") you would need to be more specific on what you need to know.

Anyway let me know if you have more questions.

 

met vriendelijke groet,

jelte

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

0 Likes