Message 1 of 4
Mark feature with convert to geometry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I'm struggling to get the converted geometries from a text box to get added to the selection.
i picked up the rule from another thread.
if i comment out line 69 to 73, the rule works.
Ideally i'd also like to just use the <Part number> iproperty in the text box rather than create a custom property.
Sub Main() 'This Is a Ilogic Rule To create a Mark From a textbox For engraving ' 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)) ' ===================== Create a Custom Parameter in Iproperties "Tekeningnummer"====================== 'Creating Custom IProperty with filenumber in it calling it Tekeningnummer iProperties.Value("Custom", "Tekeningnummer") = ThisDoc.FileName(False) 'false = without extension iProperties.Value("Custom", "Tekeningnummer") = (Left(ThisDoc.FileName(False),14)) 'Creating a UserParameter Where the Tekeningnummer value Is put In Dim PropValue As String = iProperties.Value("Custom", "Tekeningnummer") '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(0.5, 1), sText) '==================== Creating an Objectcollection to be Marked ====================== Dim oSketchObjects As ObjectCollection oSketchObjects = ThisApplication.TransientObjects.CreateObjectCollection ' Get all entities In the sketch Dim oEntities As Object 'Dim oSketchText As TextBox oTextBox.ConvertToGeometry("ISO") For Each oEntities In oSketch.SketchEntities oSketchObjects.Add(oEntities) Next For Each oSketchText In oSketch.TextBoxes oSketchObjects.Add(oSketchText) Next ' Dim oSketchEntity As Object 'For Each oSketchEntity In oTransientGeometry ' oSketchObjects.Add(oTransientGeometry) '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 'oTextBox.ConvertToGeometry("ISO") oMark = oMarkFeatures.Add(oMarkDef) '==================== End Sub