I know the sketch name (but don't know what it is in the window). Although, I renamed in order the browser, browsing through the sketch browser to locate a sketch is still a little bit harder.
In order to edit the sketch (sketch name is known), I would like to seek help with an ilogic code that will show in the sketch in the sketch browser.
I thank for all replies.
Solved! Go to Solution.
Solved by RoyWickrama_RWEI. Go to Solution.
Solved by Owner2229. Go to Solution.
Hey, you can use this:
Dim oDoc As Document = ThisApplication.ActiveDocument Dim oCD As ComponentDefinition = oDoc.ComponentDefinition Dim oSketch As Sketch = oCD.Sketches.Item("MySketchName")
If oSketch Is Nothing Then Exit Sub oSketch.Edit() Try 'Do something with the sketch Catch
End Try oSketch.ExitEdit()
Or if you really just want to select it:
Dim oDoc As Document = ThisApplication.ActiveDocument Dim oCD As ComponentDefinition = oDoc.ComponentDefinition Dim oSketch As Sketch = oCD.Sketches.Item("MySketchName")
If oSketch Is Nothing Then Exit Sub
oDoc.SelectSet.Select(oSketch)
Thanks a lot in replying to my request. It is so great. Mostly, I like the 2nd option. My iLogic is productive with your help.
Thanks a lot in replying to my request. It is so great. Mostly, I like the 2nd option. My iLogic is productive with your help.
I incorporated a lot of iLogic in my ideal iLogic rich project (but more to go). Thank you.
You're welcomed.
I further revised the code a little bit (because it was giving an error message in case I input invalid data) so that it runs better.
Dim oDoc As Document = ThisApplication.ActiveDocument Dim oCD As ComponentDefinition = oDoc.ComponentDefinition Dim oSketch As Sketch Dim oFindSketch As String 100: oFindSketch = "SK-00000, example. Type sketch name." oFindSketch = InputBox("Prompt", "Title", oFindSketch, MessageBoxButtons.YesNoCancel) For Each oSketch In oDoc.ComponentDefinition.Sketches If Not oFindSketch = oSketch.Name Then Counter = 0 Else Counter = 1 oSketch = oCD.Sketches.Item(oFindSketch) Exit For End If Next If Counter = 0 Then 'Not OK oInfo = MessageBox.Show("The sketch name typed in is " & "NOT VALID." _ & vbLf & "Do you want to retry?", "Title", MessageBoxButtons.YesNo) If oInfo = vbYes Then Goto 100: Else If oInfo = vbNo Then 'Do noting End If Else If Counter = 1 Then 'OK oDoc.SelectSet.Select(oSketch) End If
Sometimes it is unclear that there is some object selected
Reasons may be
Object is not visible in browser (sketch hidden inside feature)
Or there are too many objects (object list is longer than vertical app window size can fit)
What else could be done to set focus exactly on the selected browser object ?
You are right. Thanks a lot.
Please try with the attached rule.
Note: I got help from one of the postings by Curtise Weguespack (see the link below).
My profuse thanks go to Curtise as well.
Ref: https://forums.autodesk.com/t5/inventor-customization/ilogic-underconstrained-sketches/td-p/3104766
Thank you it helped a bit for single object selection.
In fact I'm writing app that selects several objects (features) of the part.
In some cases (Derived IAM) features are hidden two levels deep.
I've added oControlDef.Execute after selecting each feature but it does not open second level for all but first feature. Seems like I need to learn more regarding browsers...