Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic - Naming solid bodies with dropdown list as a standard name

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
Anonymous
2170 Views, 9 Replies

iLogic - Naming solid bodies with dropdown list as a standard name

Hi Everyone

This is my first post and I have a tricky request.

Can someone help to achieve the renaming of solid bodies by array list - click on the solid body and rename by a pre-defined name list (dropdownlist) from excel or text document? 

This is a mix from the post:

http://inventortrenches.blogspot.ae/2012/02/ilogic-to-rename-all-solid-bodies.html

and

http://inventortrenches.blogspot.ae/2013/07/ilogic-add-standard-virtual-parts-from.html

and

http://inventortrenches.blogspot.ae/2013/01/ilogic-solid-body-visibility.html

 

The main idea is to always assure same part names when making components for example for furniture like TOP PANEL or RIGHT PANEL and this in an easy way to avoid writing always over and over again same naming. 

 

Your input and ideas are well appreciated.

 

Thanks

 

9 REPLIES 9
Message 2 of 10
MechMachineMan
in reply to: Anonymous

Here is an iLogic solution.

 

To be ran from the part file.

 

Add extra names by just adding more lines of oList.Add, following the current format.

 

It runs in a loop until you hit escape during selection or use the exit button during list box.

 

Sub Main()
	Dim oList As New List(Of String)
	oList.Add("Top")
	oList.Add("Right Panel")
	
	Do
		oBody = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartBodyFilter, "Pick Body to Rename")
		If oBody Is Nothing
			GoTo ExitSelectLoop
		End If
		oName = InputListBox("Select the name for this body", oList)
If oName <> "" Then oBody.Name = oName
Else
GoTo ExitSelectLoop
End if Loop ExitSelectLoop: End Sub

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 3 of 10
Anonymous
in reply to: MechMachineMan

.... you guys rock!

 

I tested it and is exactly what I am looking for - awesome and well done. 

 

Wich I would have the knowledge you guys have - but working on it. 

 

Thanks for your support!

 

 

Message 4 of 10
Anonymous
in reply to: Anonymous

Not sure if this is the best place to post this follow-on request, but seems to be the latest thread referencing this rule: 

 

http://inventortrenches.blogspot.ae/2012/02/ilogic-to-rename-all-solid-bodies.html

 

I have been trying to add a simple If /Then condition to this rule so that it will only rename bodies in a multi-body part that are marked for export (or, alternatively, only bodies that are visible).  Often I have bodies in a multi-body part that will not make the cut to be a part in the assembly for which I am making components, and therefore I would like the rule to skip these bodies when numbering in sequence so the resulting assembly does not have gaps in part numbers.  I have also tried to make the skipping behavior contingent on body visibility, but always get an error with my code (which I’m sure is just totally incorrect).  Any thoughts?  Seems like this should be an easy one for you guys. 

 

Thanks in advance for any help. 

 

Message 5 of 10
MechMachineMan
in reply to: Anonymous

@Anonymous You probably would have been better making a new thread.

 

 However, based on the code in your supplied link

 

and using the API help to figure out the available calls:

(found here: http://help.autodesk.com/view/INVNTOR/2019/ENU/?guid=GUID-F20C9F1B-2BB1-4B7E-BA3E-FF1731F9F0DA)

 

The modified code should look something like this:

'check for custom iProperty and add it if not found
Dim prefix As String = "Prefix"
customPropertySet = ThisDoc.Document.PropertySets.Item _
("Inventor User Defined Properties")

Try
         prop= customPropertySet.Item(prefix)
Catch
      ' Assume error means not found
            customPropertySet.Add("", prefix)
End Try

'write the part number to the Prefix iProperty if it is empty
if iProperties.Value("Custom", "Prefix") = "" Then
iProperties.Value("Custom", "Prefix") = iProperties.Value("Project", "Part Number") & "_"
else
end if

'check that this active document is a part file   
Dim partDoc As PartDocument
If ThisApplication.ActiveDocument.DocumentType <> kPartDocumentObject Then
MessageBox.Show ("Please open a part document", "iLogic")
End If

'define the active document
partDoc = ThisApplication.ActiveDocument
Dim solid As SurfaceBody
Dim i As Integer

'get input from user
prefix = InputBox("Enter a prefix for the solid body names", "iLogic", iProperties.Value("Custom", "Prefix"))

'write input back to custom iProperty
iProperties.Value("Custom", "Prefix") = prefix
i = 1
'renam
e all solid bodies incrementing suffix For Each solid In partDoc.ComponentDefinition.SurfaceBodies
If solid.Exported = True solid.Name = prefix + IIf(i < 10, "0" + CStr(i), CStr(i))
end if
i = i + 1 Next

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 6 of 10
Anonymous
in reply to: MechMachineMan

Thanks 

 

 

 

 

Message 7 of 10

Hi All,

 

The supplied code works great, however as was previously mentioned is there a way

to only rename visible solids in this manner?

 

Or alternately is there a way to rename only selected solids

potentially using pick?

 

Let me know what you think

Regards

Bruce

 

 

Message 8 of 10
MechMachineMan
in reply to: Anonymous

@Anonymous

 

Yes. Move the

i = i + 1

line inside of the If statement that controls the processing criteria.

ie; move it up 2 lines above the "End If".


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 9 of 10

@bruce.blundell

 

Sure. Use the appropriate call available on the solid object with an appropriate "If" statement to cause the rule to process as you require. (Much the like If solid.Exported = True, except more like "If solid.Visible = true")

 

Alternatively, you can search around more on the forums to find code that would process a "select set" (which is better than pick functionality in this case) and figure out how to modify the code to use that as a criteria instead of the "if" statements.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 10 of 10

Perfect that's great, works a treat

Thanks

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Customer Advisory Groups


Autodesk Design & Make Report