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: 

ilogic partnumber change in assembly and mass unit change

1 REPLY 1
Reply
Message 1 of 2
toon.gielen
453 Views, 1 Reply

ilogic partnumber change in assembly and mass unit change

Hi all.

 

I've got an assembly with parts. I need to change the PN of each part to be the same as the filename as well as the unit of mass should be kg instead of lbppounds.

 

I managed to change globally the lbpounds of the parts to kg. The bom was also updated. 

 

But I need to add a rule in order this change is permanent. (I use the parts in other projects). 

 

With the rule (under) : it works only once. When I reopen the assembly with all the parts, the unit is again lb pounds. 

 

Specific question. I need to have the kg unit for each part. Permanently stored in the properties of the individual part. as well as the partnumber should be the filename. For the partnumber change for each part, I tried a code but it doesnt work. Any suggestions please?

 

code for mass unit change. (only works for the assembly bom, I need to have it work for each part permanently)

 

SyntaxEditor Code Snippet

'get input from user
oUnit = InputRadioBox("Select a unit of measure type", "Metric", "Imperial", False, "ilogic")

If oUnit = True Then 
'set to millimeter
oUOM_1 = UnitsTypeEnum.kMillimeterLengthUnits 
'set to kilogram
oUOM_2 = UnitsTypeEnum.kKilogramMassUnits
Else 
'set to inch
oUOM_1 = UnitsTypeEnum.kInchLengthUnits 
'set to pounds mass
oUOM_2 = UnitsTypeEnum.kLbMassMassUnits         
End If

'Define the open document
Dim openDoc As Document
openDoc = ThisDoc.Document

'Look at all of the files referenced in the open document
Dim docFile As Document 
For Each docFile In openDoc.AllReferencedDocuments    
    'look at only part files
     If docFile.DocumentType = kPartDocumentObject Then    
     
     'set mass units 
    docFile.unitsofmeasure.MassUnits = oUOM_2 
    'rebuild to update the display
    docFile.Rebuild
    End If
    
Next    
iLogicVb.UpdateWhenDone = True



Thank you for helping me.

 The fault code for the partnumber change 

 

SyntaxEditor Code Snippet

'Define the open document
Dim openDoc As Document
openDoc = ThisDoc.Document

'Look at all of the files referenced in the open document
Dim docFile As Document 
For Each docFile In openDoc.AllReferencedDocuments    
    'look at only part files
     If docFile.DocumentType = kPartDocumentObject Then    
     
     'set mass units 
    docFile.unitsofmeasure.MassUnits = oUOM_2 
    
     'set partnumber
      docfile.iProperties.Value("Project", "Part Number")=docfile.FileName(False)
    
    
    'rebuild to update the display
    docFile.Rebuild
    End If
    
Next    
iLogicVb.UpdateWhenDone = True

 

1 REPLY 1
Message 2 of 2

@toon.gielen,

 

To retain part number and mass unit change, saving the document (docFile.Save()) would be helpful.

 

Can you please provide sample Inventor files to investigate? Please make sure that files are non confidential.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



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

Post to forums