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: 

Material system iProperty

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
cdellea
560 Views, 5 Replies

Material system iProperty

Hi all,

 

It seems that since Inventor 2023, the system iProperty "Material" from "Design Tracking Properties" PropertySet cannot be set through API anymore.

I have tried with Inventor 2022.5, it is working. I can set this property in Parts (.ipt) and Drawings (.idw). I have not tested in another file type. But with Inventor 2023.4, this is not working anymore. Trying to set the value of this property (in a part or a drawing) throw an exception.

 

Has anybody experience the same problem ?

 

Is there any documentation about this change (I have not found anything...) ?

 

Thanks

Labels (3)
5 REPLIES 5
Message 2 of 6
Frederick_Law
in reply to: cdellea

My old 2018 Addin to change material from assembly still work.

I did not use iProperties:

  Private Sub SetPartMaterial(oMatDoc As PartDocument, oMatName As String)
    Dim oPartCompDef As PartComponentDefinition
    oPartCompDef = oMatDoc.ComponentDefinition

    ' Get the selected material
    Dim oMaterial As Material
    oMaterial = oMatDoc.Materials.Item(oMatName)

    ' Change the part material
    Try
      oPartCompDef.Material = oMaterial
    Catch ex As Exception
      MsgBox("Failed to set Material")
    End Try

    Try
      oMatDoc.Save()
    Catch
    End Try
  End Sub
Message 3 of 6
cdellea
in reply to: Frederick_Law

Hi pineapple,

 

Thank you for your answer.

 

Yes, I agree. Changing material through the member ComponentDefinition.Material works well. In fact, in a part, chaging the ComponentDefinition.Material makes the Material iProperty to be changed. But this is not the problem I am facing. My problem is that I cannot set the value of Material iProperty.

 

My problem, to be more precise, is very contextual. And is linked to changing the value of Material iProperty in drawings (.idw). Why ? Because historically, this iProperty is mapped to a Vault UDP for some of my customers. And this is not working anymore...

Message 4 of 6
Frederick_Law
in reply to: cdellea

I don't remember " the system iProperty "Material" from "Design Tracking Properties"".

It could be in "User Defined Properties".

Material and Appearance changed after 2012.  I don't remember how the API work before that.

Also Drawing doesn't have "Material" property.

Drawing always get "Material" from part or assembly.

 

I'm confused 😵

Message 5 of 6
WCrihfield
in reply to: cdellea

Hi guys.  The iProperty named "Material" that is within the "Design Tracking Properties" PropertySet is ReadOnly, according to the online help documentation.  And it seemed to me like it had been that way for quite a while, but I could be wrong about how long it has been that way.  Here is the link to the PropertiesForDesignTrackingPropertiesEnum, which contains notes about most of the iProperties within that PropertySet.  There are actually two properties related to the material (Material & Material Identifier), but one is a bit odd, containing a concatenated material library path with the material name.  You can still use the iProperties.Material (Link1, Link2) iLogic snippet though.  The PartComponentDefinition.Material property has actually been 'hidden' for quite a few years now, so I never use it.  I pretty much just always use the PartDocument.ActiveMaterial property.

 

Edit:  Also, all of the properties within first 3 PropertySets are standard in all documents, no matter their type, but sometimes they just don't have any values, or a useless value.  The fourth PropertySet is always the 'Custom' one, and it is always present, but obviously does not have any properties, by default.  Generally the Material iProperty is 'driven' rather than 'driving', to put it in dimension constraint terms, so setting the 'real' iProperties's value should not change the material of the part anyways, but the iProperties.Material iLogic snippet will change the part's material (or the material of a component).  Then changing the part's material should automatically change the value of the iProperty.  I know, it may not have always been that way though.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 6 of 6
cdellea
in reply to: WCrihfield

Hi,

 

Thank you for the information. Indeed, I use ActiveMaterial to modify the material of a part. The Design Tracking iProperty Material was used for binding purpose into Vault. As my customer wants the model material to be visible in a drawing property inside Vault, the binding on Material property was the best choice (could bind the property on a Vault UDP for parts and drawings).

 

I didn't notice in the API documentation that this property should be Read Only because till version 2022, it wasn't (even if already mentionned in documentation). And now, drawings with the material iproperty set keep the last value set in 2022 and cannot be changed or removed. It will keep the value forever... 😛

 

Anyway, I will have to provide a new mechanism for my customer.

 

Again, thank you very much for your help and your time.

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

Post to forums  

Autodesk Design & Make Report