Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Description of solid bodies

17 REPLIES 17
Reply
Message 1 of 18
GosponZ
689 Views, 17 Replies

Description of solid bodies

 

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.

bodies.JPG

17 REPLIES 17
Message 2 of 18
Vladimir.Ananyev
in reply to: GosponZ

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

BodiesNames.jpg  

You may save every oBody.Name to the Description property in the oDef.Document object.

Cheers,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 3 of 18
GosponZ
in reply to: Vladimir.Ananyev

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.

solid.JPG

solid 2.JPG

Thank you

Message 4 of 18
GosponZ
in reply to: GosponZ

Vladimir,

didn't find yet what i'm looking.

Thank you

Message 5 of 18
adam.nagy
in reply to: GosponZ

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. 



Adam Nagy
Autodesk Platform Services
Message 6 of 18
GosponZ
in reply to: adam.nagy

 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

Message 7 of 18
GosponZ
in reply to: GosponZ

I'll start beleive that trere is no solution for this case. 😞

Message 8 of 18
adam.nagy
in reply to: GosponZ

These are the steps I'm taking. Starting with a multi solid part:

comp1.png

 

Then I click Make Components:

comp2.png

 

I fill the dialog like this - the component name is different from the body's name:

comp3.png

 

Here is the result:

comp4.png

 

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

 



Adam Nagy
Autodesk Platform Services
Message 9 of 18
GosponZ
in reply to: adam.nagy

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

Message 10 of 18
adam.nagy
in reply to: GosponZ

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?



Adam Nagy
Autodesk Platform Services
Message 11 of 18
GosponZ
in reply to: adam.nagy

Yes i do, and this is i beleive last part.

Message 12 of 18
GosponZ
in reply to: GosponZ

Ok should i beleive that on this one no answer?

Message 13 of 18
adam.nagy
in reply to: GosponZ

Can you share what you have so far? Is it just the assignment of original solid names to iProperty that is still missing?

 



Adam Nagy
Autodesk Platform Services
Message 14 of 18
GosponZ
in reply to: adam.nagy

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

Message 15 of 18
adam.nagy
in reply to: GosponZ

Hmmm... OK, I wrote a blog post about it:

http://adndevblog.typepad.com/manufacturing/2014/06/make-components-command-implemented-via-api.html



Adam Nagy
Autodesk Platform Services
Message 16 of 18
GosponZ
in reply to: adam.nagy

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

Message 17 of 18
adam.nagy
in reply to: GosponZ

Just create a new Module in your project and copy/paste the whole code shown in the 4th response in this thread into it:

http://forums.autodesk.com/t5/Inventor-Customization/Folder-Browser-Needed-for-VBA-7-64-bit/td-p/436...

 

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\"


Adam Nagy
Autodesk Platform Services
Message 18 of 18
GosponZ
in reply to: adam.nagy

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.

Post to forums  

Autodesk Design & Make Report