- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
is it possible create rule for assembly environment for running small description window?
When I run rule I need select part, when I select part, I can add description for this part. If I select some other part, I can again add description for this selected part. When I finish with adding description, click esc or done for exit.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @kresh.bell . Please try this code:
Dim oInvApp As Inventor.Application = ThisApplication
Dim oAsmDoc As AssemblyDocument = oInvApp.ActiveDocument
Dim oCM As CommandManager = oInvApp.CommandManager
Do
Dim oOcc As ComponentOccurrence = oCM.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, _
"Select your part...")
If oOcc Is Nothing Then Exit Sub
If TypeOf oOcc.Definition.Document Is PartDocument Then
Dim oPartDoc As PartDocument = oOcc.Definition.Document
Dim oProp As Inventor.Property = oPartDoc.PropertySets("Design Tracking Properties")("Description")
oProp.Value = InputBox("Please Enter a Description", "Description", oProp.Value)
End If
Loop
Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor
LinkedIn | My free Inventor Addin | My Repositories
Did you find this reply helpful ? If so please use the Accept as Solution/Like.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Please, can you fix minor bug? If part already have description and if I click cancel this delete exist description. Is it possible, if part already have description that cancel do nothing?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @kresh.bell ,
I started replying to this earlier but had to take a meeting, and @Andrii_Humeniuk was too fast for me! and had already provided a solution by the time I started to post this.
In any case, I had this version ready, so I'll share it also... maybe it'll help someone in the future.
It looks like the 2 versions work pretty much the same.
The primary difference I see is that Andrii's excellent version reaches down into a subassembly and gets the part, when a subassembly is selected. Whereas my example gets the subassembly description.
Also my example highlights the selected component by using the select set and puts the name in the message box, but those are minor differences.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Dim oOccurrence As ComponentOccurrence
msg = "Select a component (press ESC to exit)"
While True
oOccurrence = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, msg)
' If nothing gets selected then we're done
If IsNothing(oOccurrence) Then Exit While
oName = oOccurrence.Name
ThisApplication.ActiveDocument.selectset.select(oOccurrence)
oDesc = iProperties.Value(oName, "Project", "Description")
oDesc = InputBox(oName & " Description", "iLogic", oDesc)
If Not oDesc = Nothing Then iProperties.Value(oName, "Project", "Description") = oDesc
End While
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Curtis,
thanks again. Show selected body in your iLogic is realy very usefull.
I have one iLogic, but for part envirovment, for add chamfer to selected body. Is it posibble edit this iLogic that I see selected bodies on same way as I see selected parts in your iLogic?
Sub Main
Dim doc As Inventor.PartDocument = ThisApplication.ActiveDocument
Dim partdef As Inventor.PartComponentDefinition = doc.ComponentDefinition
Dim bodyCol As Inventor.ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
For i As Integer = 1 To partdef.SurfaceBodies.Count
Dim body As SurfaceBody = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartBodyFilter, "Select Body (Bodies). When you finish, Esc Key")
If body Is Nothing Then Exit For
If check(body, bodyCol) = False Then bodyCol.Add(body)
Next
Dim distance As Double = (Double.Parse(InputBox("Chamfer distance", "MJM iLogic", 0.707))) / 10 ' 0.707
Dim edges As EdgeCollection = ThisApplication.TransientObjects.CreateEdgeCollection()
For Each body As Inventor.SurfaceBody In bodyCol
For Each edge As Edge In body.Edges
edges.Add(Edge)
Next
Next
partdef.Features.ChamferFeatures.AddUsingDistance(edges, distance)
End Sub
Private Function check(input As Object, col As Inventor.ObjectCollection)
If col.Count = 0 Then Return False
For Each obj As Object In col
If obj Is input Then Return True
Next
Return False
End Function
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @kresh.bell
I think here we'd want to use a highlight set, to maintain the selected components as we pick.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Sub Main 'https://www.rapidtables.com/web/color/index.html '(255, 0, 0) 'red '(0, 255, 0) 'green '(0, 0, 255) 'blue '(255 255, 0) 'yellow '(255, 0, 255) 'magenta '(0, 255, 255) 'cyan Dim HLset As HighlightSet = ThisApplication.ActiveDocument.HighlightSets.Add() HLset.Color = ThisApplication.TransientObjects.CreateColor(255, 255, 0) 'yellow Dim doc As Inventor.PartDocument = ThisApplication.ActiveDocument Dim partdef As Inventor.PartComponentDefinition = doc.ComponentDefinition Dim bodyCol As Inventor.ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection While True Dim body As SurfaceBody = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartBodyFilter, "Select Body (Bodies). When you finish, Esc Key") If body Is Nothing Then Exit While If check(body, bodyCol) = False Then bodyCol.Add(body) HLset.AddItem(body) End While Dim distance As Double Try distance = (Double.Parse(InputBox("Chamfer distance", "MJM iLogic", 0.707))) / 10 ' 0.707 Catch HLset.Clear Exit Sub End Try Dim edges As EdgeCollection = ThisApplication.TransientObjects.CreateEdgeCollection() For Each body As Inventor.SurfaceBody In bodyCol For Each edge As Edge In body.Edges edges.Add(Edge) Next Next partdef.Features.ChamferFeatures.AddUsingDistance(edges, distance) HLset.Clear End Sub Private Function check(input As Object, col As Inventor.ObjectCollection) If col.Count = 0 Then Return False For Each obj As Object In col If obj Is input Then Return True Next Return False End Function
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report