I'm trying to use description of solid bodies for description of part after components are created. All my solid bodies got name by creating, but that name will be just perfect description in part description. Can you guys help me to make ilogic rule for this problem. Thanks to All.
The following demo rule prints referenced bodies names for every component in the active assembly.
Sub Main() Dim oAsmDoc As AssemblyDocument = ThisDoc.Document Dim oAsmDef As AssemblyComponentDefinition = oAsmDoc.ComponentDefinition Dim oOccs As ComponentOccurrences = oAsmDef.Occurrences Dim St As String = "" For Each oOcc As ComponentOccurrence In oOccs Try Dim oDef As PartComponentDefinition = oOcc.Definition Dim oDerivedPartComponent As DerivedPartComponent = _ oDef.ReferenceComponents.DerivedPartComponents.Item(1) Dim oSolidBodies As ReferenceFeaturesEnumerator = _ oDerivedPartComponent.SolidBodies Dim oReferenceFeature As ReferenceFeature = oSolidBodies.Item(1) Dim oBody As SurfaceBody = oReferenceFeature.ReferencedEntity Dim Name As String = oBody.Name St = St & vbNewLine & Name Catch 'some error End Try Next Beep() MsgBox(St) End Sub
You may save every oBody.Name to the Description property in the oDef.Document object.
Cheers,
Ok, i think like this. When making components i will change Component Name in future part number in this case 01 ,02 03. This number will stay as part number, but solid bodies name in this case prism, cilinder and cube will be in iproperties description.
Thank you
I'm not sure I fully understand what you need. Are you trying to reimplement the "Make Components" command, or just trying to set the "Description" of the created part files to the name of the part document? - the created part documents are automatically named based on the name of the Solids.
This Solid bodies names i would like to use in iProperties description after i make components. If you take look on picture .Selected bodies are my parts with desired names in this case cilinder prism and cube, and this names i would like to use thru ilogic to be description of my parts after i make components. This numbers in components name (001-001..) are part numbers and they are just fine.
Thank you
These are the steps I'm taking. Starting with a multi solid part:
Then I click Make Components:
I fill the dialog like this - the component name is different from the body's name:
Here is the result:
You can see that the part knows what Solid Body it is using - "Box1" / "Box2" is there in the highlighted name. And this is how we can get to it e.g. from the assembly "MultiSolid.iam". Once you have it you can set the iProperty with it.
Sub TestMultiSolid() Dim doc As AssemblyDocument Set doc = ThisApplication.ActiveDocument Dim occ As ComponentOccurrence Set occ = doc.ComponentDefinition.Occurrences(1) Dim pcd As PartComponentDefinition Set pcd = occ.Definition MsgBox (pcd.Features.ReferenceFeatures(1).ReferencedEntity.name) End Sub
Thanks for answer, but i'm still far away from answer. I do same as you did for years. Same every day. But your last picture browser bar with 2 rect. hi lite state for Box 1 and Box 2. Those two i would like to have in iPropertie Description. Above code from Vladimir gives me msgbox with what i want,but i don't need to see msg box, i need in every part ipropertie description.
In rule you sugest i got msg but for only one part . I'm trying to understand how to capture those names and send them in each part .
Could you guys guide me in right direction little bit more.
Thank you
Are you trying to automate the whole part creation process or just setting the iProperties once they documents were created using the Make Components command?
Can you share what you have so far? Is it just the assignment of original solid names to iProperty that is still missing?
I would share no problem but do not have what to share. I still have only what Vladimir posted and i'm trying to add some codes to assign solid names to iProperties. Only that is missing to complete this rule.
Thank you
Hmmm... OK, I wrote a blog post about it:
http://adndevblog.typepad.com/manufacturing/2014/06/make-components-command-implemented-via-api.html
Adam, thank you very much.
I still have question. I tryed code and is working perfect, but some upgrade on code would be great. If is possible to access Make component dialog before start to make assembly. I would like to choose where my bodies (components) will go. It is not same folder all the time, and I hope i'm not asking to much.
Thanks again
Just create a new Module in your project and copy/paste the whole code shown in the 4th response in this thread into it:
Now you can easily update the beginning of the code in my post with this:
' Run this inside a Multi-Solid part Sub MakeComponentsProgrammatically() ' Folder to place the new components: ' assembly and subcomponents Dim f As String: f = FolderBrowse("Select Target Folder", "") '"C:\temp\test2\"
The codes are working perfect but it still need some work on it. The saving is cool, but it is skipped Component Name which is also in whole this rule very important (for me). Now, if is possible to get that dialog window to appear and get possibility to give Component Name and that is what will make Part Number in iProperies for each part in assembly. That will be really cool.
I appreciate guys for help
Can't find what you're looking for? Ask the community or share your knowledge.