iLogic to place point and mark for etching
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
We've recently decided to etch all of our part numbers onto our sheet metal parts for easier identification on the shop floor, and I'm trying to make a rule to get the process somewhat automated so it's less of a slog to get through the thousands of parts we're going to have to go back and add the mark to.
I've cobbled something together from other examples of similar instances got it mostly to where I want it, but I'm hung up on some finer points.
Ideally, I'd like the rule to prompt the user to select a face (as in line 13-16), create a new sketch, place a point inside of the new sketch (location doesn't matter, as it will be moved to a more precise location later), and carry on with the rest of the rule so that all we have to do is run the rule and reposition the mark.
It would also be great if the mark command would select all of the geometry and finalize itself, but none of what I've been able to find has worked out.
Currently, I've just been manually placing a mark on the target face and running the rule below to get the mark in place.
Any help in the matter would be greatly appreciated.
' Creates a mark from a textbox for engraving part numbers
Dim oPartDoc As PartDocument
oPartDoc = ThisApplication.ActiveDocument
Dim oCompDef As PartComponentDefinition
oCompDef = oPartDoc.ComponentDefinition
' Set a reference to the transient geometry object
Dim oTransGeom As TransientGeometry
oTransGeom = ThisApplication.TransientGeometry
' Select Face to dimension for the new sketch
Dim oFrontFace As Face
oFrontFace = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select Surface to Place Text On.")
' Create a new sketch on this face
Dim oSketch As PlanarSketch
oSketch = oCompDef.Sketches.Add(oFrontFace)
' Determine where in sketch space the point is
Dim oCornerPick As SketchPoint
oCornerPick = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kSketchPointFilter, "Select Point to Place Text On.")
' Convert the selected point to SketchPoint if necessary
Dim oCorner As Point2d
oCorner = oTransGeom.CreatePoint2d(oCornerPick.Geometry.X, oCornerPick.Geometry.Y)
' Get text from iProperties
Dim sText As String
sText = iProperties.Value("Project", "Part Number")
' Set Font Size
Dim oTextSize As Decimal
oTextSize = 0.47752
' Create text box with formatted text
Dim oTextBox As TextBox
oTextBox = oSketch.TextBoxes.AddFitted(oCorner, sText)
' Apply formatted text with the specified font size
oTextBox.FormattedText = "<StyleOverride FontSize='" & oTextSize & "cm'>" & sText & "</StyleOverride>"
' Convert the text box to geometry
oTextBox.ConvertToGeometry("SIMPLEX8")
' Start the feature command (if needed, depending on functionality)
ThisApplication.CommandManager.ControlDefinitions.Item("PartMarkingCmd").Execute()