Hi,
Is there a way to use iLogic to replace a block used in a sketch so that each block corresponds with a different part via iPart?
I know my phrasing of my question is poor so here is an example of what I am looking for:
I have 26 cubes for each of the 26 letters in the alphabet. Each of the cubes are the same exact dimensions but the only change is that each cube has a different letter. I have created each letter as a sketch block which will be extruded from the front top face (the font that I tried to use had issues with the emboss feature so I had to recreate the letters myself). To make things easier, I am using iParts to streamline my designing. Is there a way to define a parameter using iParts or iLogic so that say the sketch block with letter A is used with cube 1, the block with letter B used with cube 2 and so on?
Thank you to anyone who is able to provide assistance,
Zach
Solved! Go to Solution.
Solved by zpickA9TX3. Go to Solution.
Hi! I don't believe there is a workflow to replace sketch blocks. If there was no manual workflow, more than likely the iLogic code would not exist. Also, iPart is designed to generate library parts for reuse purpose.
Forget about sketch block for a second. If I understood your request correctly, you would like to drive the sketch text using iLogic, right? There is a workflow you may consider. Text parameters are not supported on iPart author table. But, iProperty is allowed. Here is what you can do.
1) Create a custom iProperty called "Alphabet."
2) Add "Alphabet" as a column on the iPart table.
3) For each member row, enter the desirable letter.
4) Create an iLogic rule assigning this custom property to a pre-defined text parameter. Enable property change/parameter change trigger.
5) In the text sketch, reference the text parameter.
6) Generate the members.
Please try it out and see if it works for you.
Many thanks!
Hi Johnson,
Thank you for your response. I should clarify that the each letter is actually geometry. I was originally going to make a shx text in AutoCAD however curves and lines came out very jagged when I tried the font out hence to why I am creating sketch blocks for each individual letter. In other words, I am not using sketch text, rather actual geometry.
-Zach
Hi! Then I don't have a better approach. You will need to do it one by one. I am not aware of a workflow swapping out sketch blocks or profiles without failures.
Many thanks!
Hello @zpickA9TX3 !
Great to see you here on Inventor Customization Forum.
Did you find a solution?
If yes, please click on the "Accept as Solution" button as then also other community users can easily find and benefit from the information.
If not please don't hesitate to give an update here in your topic so all members know what ́s the progression on your question is and what might be helpful to achieve what you ́re looking for. 🙂
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям! | Do you find the posts helpful? "LIKE" these posts!
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
I haven't tried replacing the sketch under an existing extrusion feature before, but I do regularly update older files, by totally deleting all unused, and replacing all used Borders, Border Definitions, Title Blocks, Title Block Definitions, Sketched Symbols, & Sketched Symbol Definitions.
Wesley Crihfield
After weeks of searching the forums and scavenging the help documents, I finally got things working exactly how I wanted it to work. I have attached the code I developed so that others can use it as a reference. I ended up having to use a combination of VBA and iLogic to get it all working. Because the face for which I wanted the block to be on was created by a loft feature, you will see that the VBA code references the loft as the face to make the planar sketch. In addition, some code is used to select the appropriate face on the loft feature. One can redefine this to fit their needs.
To get this working with iParts, I defined 2 User Parameters called BlockName and BlockName_Index. BlockName_Index runs via iLogic code to change the value of the BlockName parameter. BlockName is implemented into the VBA code so that the code would select the block to place based on the values defined for BlockName. BlockName_Index can be changed via iParts table so that each iPart member can use a different block. For example, if BlockName_Index is 1 ul, the value of BlockName will be A, 2 ul will be B, and so on. The BlockName values can be changed in the iLogic code to match the name of the particular block. BlockName_Index must keep the format of # ul in order for this all to work. Depending on how many iPart members a person has, one can match the iLogic code to their specific needs.
Another User Parameter, d65, was defined for extruding the block. One can change the name of this parameter in the VBA code to match another user parameter of their choosing. This parameter can be implemented into an iParts table so that different members can have different extrusion values to fit their needs.
Some errors that occur are as follows:
I hope that this helps anyone who is looking to automate the same functionality. Keep in mind that this code automates this process so if any values need to be changed after this code runs, one needs to undo or delete the actions executed by the code.
-Zach
VBA Code:
Option Explicit
Public Sub InsertSketchBlockDefinition()
' Set a reference to the part document.
' This assumes a part document is active.
Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.ActiveDocument
Dim oCompDef As PartComponentDefinition
Set oCompDef = oPartDoc.ComponentDefinition
' Create a new sketch on the X-Y work plane.
'Dim oSketch As PlanarSketch
'Set oSketch = oCompDef.Sketches.Add(oCompDef.WorkPlanes(4))
Dim oLoft As LoftFeatures
Set oLoft = oCompDef.Features.LoftFeatures
Dim oFaces As Faces
'This can be changed to .SideFaces, .EndFaces, or .StartFaces
'But .Faces will let you choose between all faces
Set oFaces = oLoft.Item(1).Faces
Dim oSketch As PlanarSketch
'Put a sketch on the first face (1) - change to suit
Set oSketch = oCompDef.Sketches.AddWithOrientation(oFaces(5), oCompDef.WorkAxes.Item(2), True, True, oCompDef.WorkPoints(1))
'Get User Parameter
Dim oParams As Parameters
Set oParams = oCompDef.Parameters
Dim oUserParams As UserParameters
Set oUserParams = oParams.UserParameters
' Set a reference to the definition named "A"
Dim oSketchBlockDef As SketchBlockDefinition
Set oSketchBlockDef = oCompDef.SketchBlockDefinitions.Item(oUserParams.Item("BlockName").Value)
Dim oPosition As Point2d
Set oPosition = ThisApplication.TransientGeometry.CreatePoint2d(0, 0)
' Insert the sketch block definition
Call oSketch.SketchBlocks.AddByDefinition(oSketchBlockDef, oPosition).Explode
Dim oProfile As Profile
Set oProfile = oSketch.Profiles.AddForSolid
' Extrude the sketch.
Dim oExtrudeDef As ExtrudeDefinition
Set oExtrudeDef = oCompDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfile, kJoinOperation)
Call oExtrudeDef.SetDistanceExtent("d65", kPositiveExtentDirection)
Dim oExtrude As ExtrudeFeature
Set oExtrude = oCompDef.Features.ExtrudeFeatures.Add(oExtrudeDef)
End Sub
iLogic Code:
iLogicVb.UpdateWhenDone = True
Select Case BlockName_Index
Case 1
Parameter("BlockName") = "A"
Case 2
Parameter("BlockName") = "B"
Case 3
Parameter("BlockName") = "C"
Case 4
Parameter("BlockName") = "D"
Case 5
Parameter("BlockName") = "E"
Case 6
Parameter("BlockName") = "F"
Case 7
Parameter("BlockName") = "G"
Case 8
Parameter("BlockName") = "H"
Case 9
Parameter("BlockName") = "I"
Case 10
Parameter("BlockName") = "J"
Case 11
Parameter("BlockName") = "K"
Case 12
Parameter("BlockName") = "L"
Case 13
Parameter("BlockName") = "M"
Case 14
Parameter("BlockName") = "N"
Case 15
Parameter("BlockName") = "O"
Case 16
Parameter("BlockName") = "P"
Case 17
Parameter("BlockName") = "Q"
Case 18
Parameter("BlockName") = "R"
Case 19
Parameter("BlockName") = "S"
Case 20
Parameter("BlockName") = "T"
Case 21
Parameter("BlockName") = "U"
Case 22
Parameter("BlockName") = "V"
Case 23
Parameter("BlockName") = "W"
Case 24
Parameter("BlockName") = "X"
Case 25
Parameter("BlockName") = "Y"
Case 26
Parameter("BlockName") = "Z"
End Select
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям! | Do you find the posts helpful? "LIKE" these posts!
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.