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: problem to change material

1 REPLY 1
SOLVED
Reply
Message 1 of 2
michaelackermann1187
922 Views, 1 Reply

ilogic: problem to change material

Hello,

 

at first sorry for my bad English. I found an ilogic who is working very well but I have one problem:

It is changing my material in librarys too. I like to change code in this way that it changes only parts which are in the

folder of the iam. Maybe something with ThisDoc.PathAndFileName(False)?

 

 

 

Here is the Code I use:

 

For Each ComponentOccurrence In ThisApplication.ActiveDocument.ComponentDefinition.Occurrences

If iProperties.Value ("Custom", "Werkstoff") = "1.4301" Then
If iProperties.MaterialOfComponent (ComponentOccurrence.Name) = "St 37-2" Then
iProperties.MaterialOfComponent (ComponentOccurrence.Name) = "1.4301"
End If
End If

If iProperties.Value("Custom", "Werkstoff") = "St 37-2" Then
If iProperties.MaterialOfComponent (ComponentOccurrence.Name) = "1.4301" Then
iProperties.MaterialOfComponent(ComponentOccurrence.Name) = "St 37-2"
End If
End If

Next

--------------------------------
Best Regards
Michael

 

1 REPLY 1
Message 2 of 2

Hi Michael,

if i understand your requirements you will solve your issue with something like this.

 

 

oDoc = ThisDoc.Document
aPath = ThisDoc.Path

For Each cOcc In oDoc.ComponentDefinition.Occurrences
oPath = Replace(cOcc.Definition.Document.File.FullFileName, _
					"\" & cOcc.Definition.Document.DisplayName, "")
If oPath = aPath Then
	If iProperties.Value ("Custom", "Werkstoff") = "1.4301" Then
		If iProperties.MaterialOfComponent (cOcc.Name) = "St 37-2" Then
			iProperties.MaterialOfComponent (cOcc.Name) = "1.4301"
		End If
	End If
	If iProperties.Value("Custom", "Werkstoff") = "St 37-2" Then
		If iProperties.MaterialOfComponent (cOcc.Name) = "1.4301" Then
			iProperties.MaterialOfComponent(cOcc.Name) = "St 37-2"
		End If
	End If
End If
Next

 

 

Bregs

Rossano Praderi



--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------

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

Post to forums  

Autodesk Design & Make Report