- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi everyone
Extremely helpful community!
I am not a programmer/coder, but trying to put together an iLogic to help my and my coleagues workload. We have many parts that we need to etch on our laser. Idea is to pick a face on the part, create sketch text with iProperties"Part Number" and iProperties"Revision Number" ideally as a single text box so they can be dragged together (stay aligned). Then create Mark Through from that text, while forcing the text height to change to 6 (for example).
This is what I run at the moment, I have another rule that is the same just for the "Revision Number" property, which is not ideal and would like to combine it in one single rule. I cant pick text height and Mark Though with the below rule. Any help would be appreciated, thanks a lot!
Sub Main() ' a reference to the currently active document. ' This assumes that it is a part document. 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 '================ Pasted to pick the face where the Mark has to come ============================ 'Select Face and Edges to dimension sketch circles from Dim oFrontFace As Face = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select Surface to Place Text On") '============================================================ ' Create a new sketch on this face oSketch = oCompDef.Sketches.AddWithOrientation(oFrontFace, _ oCompDef.WorkAxes.Item(1), True, True, oCompDef.WorkPoints(1)) ' Determine where in sketch space the point (0.5,0.5,0) is. Dim oCorner As Point2d oCorner = oSketch.ModelToSketchSpace(oTransGeom.CreatePoint(0.5, 0.5, 0)) 'Creating a UserParameter Where the chosen iProperties value Is put In Dim PropValue As String = iProperties.Value("Project", "Part Number") 'updates the user-defined Text Parameter TagName = PropValue '================================ Create a textbox in the Sketch to place the Iporp Tekeningnummer ==================== ' Create Text With simple String As Input. Since this doesn't use ' any Text Overrides, it will Default To the active Text Style. Dim oTG As TransientGeometry oTG = ThisApplication.TransientGeometry Dim sText As String sText = TagName Dim oTextBox As TextBox oTextBox = oSketch.TextBoxes.AddFitted(oTG.CreatePoint2d(1, 1), sText) '==================== Creating an Objectcollection to be Marked ====================== Dim oSketchObjects As ObjectCollection oSketchObjects = ThisApplication.TransientObjects.CreateObjectCollection ' Get all entities in the sketch Dim oSketchText As Inventor.TextBox For Each oSketchText In oSketch.TextBoxes oSketchObjects.Add(oSketchText) Next '==================== Creating the Mark on the textbox ====================== Dim oMarkFeatures As MarkFeatures oMarkFeatures = oCompDef.Features.MarkFeatures ' Get a mark style. Dim oMarkStyle As MarkStyle oMarkStyle = oPartDoc.MarkStyles.Item(1) ' Create mark definition. Dim oMarkDef As MarkDefinition oMarkDef = oMarkFeatures.CreateMarkDefinition(oSketchObjects, oMarkStyle) ' Create a mark feature. Dim oMark As MarkFeature oMark = oMarkFeatures.Add(oMarkDef) '==================== End Sub
Solved! Go to Solution.