Embossed text with iLogic

Embossed text with iLogic

Anonymous
Not applicable
2,140 Views
4 Replies
Message 1 of 5

Embossed text with iLogic

Anonymous
Not applicable

Hello everybody,
I would like to place an embossed text on a part plane with iLogic.
The text should be in the middle of the size of the sheet, and scalable depending of the sheet´s size .
I want to export the plan development as dxf (and I've already made with iLogic). In the appendix two photos of help.
Thank you in advance.

Have a nice time

 

Claudio

0 Likes
Accepted solutions (1)
2,141 Views
4 Replies
Replies (4)
Message 2 of 5

rossano_praderi
Collaborator
Collaborator

Hi, the attached .ipt is a good start for your request, I suggest you to create a template like this.

 

Bregs

Rossano Praderi



--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------
0 Likes
Message 3 of 5

Anonymous
Not applicable

Hallo Rossano,

thanks for your reply.

From this point to the end I have almost already done.
My problem is to automatically create embossed text on a specific part plan with iLogic.

 

1) Identify the plan of a part (By Picking with one Dialog)

2) On this plan automatically create embossed text

3) From here to the end it´s almost already made.

 

Thank you and have a nice time.

 

Ragards,

Claudio

 

0 Likes
Message 4 of 5

rossano_praderi
Collaborator
Collaborator
Accepted solution

Hi Claudio,

the follow VBA code is a mixture of examples from the Inventor API help, has to be personalized and improved.

 

Copy/paste this code whitin a module

Option Explicit

Public Sub EmbossedText()
    ' Create a new clsSelect object.
    Dim oSelect As New clsSelect
    
    ' Set a reference to the part component definition.
    ' This assumes that a part document is active.
    Dim oCompDef As PartComponentDefinition
    Set oCompDef = ThisApplication.ActiveDocument.ComponentDefinition

    ' Call the pick method of the clsSelect object and set
    ' the filter to pick any face.
    Dim oFace As Face
    Set oFace = oSelect.Pick(kPartFaceFilter)
    
    ' Check to make sure an object was selected.
    If Not oFace Is Nothing Then
        Dim oSketch As PlanarSketch
        Set oSketch = oCompDef.Sketches.Add(oFace, True)
        oSketch.Name = "Embossed text"
        
    ' Create text with simple string as input.  Since this doesn't use
    ' any text overrides, it will default to the active text style.
    Dim sText As String
    Dim oTextBox As TextBox
    Dim oTG As TransientGeometry
    Set oTG = ThisApplication.TransientGeometry
    
    ' Simple single line text.
    sText = "Here is the last and final line of text."
    Set oTextBox = oSketch.TextBoxes.AddFitted(oTG.CreatePoint2d(oSketch.OriginPointGeometry.X, _
                                                oSketch.OriginPointGeometry.Y), sText)
    With oTextBox
        .VerticalJustification = kAlignTextMiddle
        .HorizontalJustification = kAlignTextCenter
    End With
    
    ' Add the text box to an object collection
    Dim oPaths As ObjectCollection
    Set oPaths = ThisApplication.TransientObjects.CreateObjectCollection
    oPaths.Add oTextBox
    
    ' Create a profile. Calling the AddForSolid method without any
    ' arguments will result in a profile containing all possible
    ' paths in the sketch. By passing in the text box, the profile
    ' is restricted to the input text path.
    Dim oProfile As Profile
    Set oProfile = oSketch.Profiles.AddForSolid(False, oPaths)

    ' Extrude the text.
    Dim oExtrudeDef As ExtrudeDefinition
    Set oExtrudeDef = oCompDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfile, kCutOperation)
    Call oExtrudeDef.SetDistanceExtent(0.25, kNegativeExtentDirection)
    Dim oExtrude As ExtrudeFeature
    Set oExtrude = oCompDef.Features.ExtrudeFeatures.Add(oExtrudeDef)
End If
End Sub

 

Copy/paste this code in a class named "clsSelect" (Inventor API help)

Option Explicit

' Declare the event objects
Private WithEvents oInteractEvents As InteractionEvents
Private WithEvents oSelectEvents As SelectEvents

' Declare a flag that's used to determine when selection stops.
Private bStillSelecting As Boolean

Public Function Pick(filter As SelectionFilterEnum) As Object
    ' Initialize flag.
    bStillSelecting = True

    ' Create an InteractionEvents object.
    Set oInteractEvents = ThisApplication.CommandManager.CreateInteractionEvents

    ' Ensure interaction is enabled.
    oInteractEvents.InteractionDisabled = False

    ' Set a reference to the select events.
    Set oSelectEvents = oInteractEvents.SelectEvents

    ' Set the filter using the value passed in.
    oSelectEvents.AddSelectionFilter filter

    ' Start the InteractionEvents object.
    oInteractEvents.Start

    ' Loop until a selection is made.
    Do While bStillSelecting
        ThisApplication.UserInterfaceManager.DoEvents
    Loop

    ' Get the selected item. If more than one thing was selected,
    ' just get the first item and ignore the rest.
    Dim oSelectedEnts As ObjectsEnumerator
    Set oSelectedEnts = oSelectEvents.SelectedEntities
    If oSelectedEnts.Count > 0 Then
        Set Pick = oSelectedEnts.Item(1)
    Else
        Set Pick = Nothing
    End If

    ' Stop the InteractionEvents object.
    oInteractEvents.Stop

    ' Clean up.
    Set oSelectEvents = Nothing
    Set oInteractEvents = Nothing
End Function

Private Sub oInteractEvents_OnTerminate()
    ' Set the flag to indicate we're done.
    bStillSelecting = False
End Sub

Private Sub oSelectEvents_OnSelect(ByVal JustSelectedEntities As ObjectsEnumerator, ByVal SelectionDevice As SelectionDeviceEnum, ByVal ModelPosition As Point, ByVal ViewPosition As Point2d, ByVal View As View)
    ' Set the flag to indicate we're done.
    bStillSelecting = False
End Sub

 

You have to run the macro and then select the plan, that's all.

 

I've used VBA because you need of an event trigger for select the plan, alternatively you have to use the .NET.

 

Bregs

Rossano Praderi



--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------
Message 5 of 5

Anonymous
Not applicable

Hallo Rossano,

Thanks you very much. 
Your example has helped me a lot. I think I will be able to arrive at the end.

All the best.

 

Regards,

Claudio

0 Likes