Jump to content

Assign materials


pizarro

Recommended Posts

1.- Differentiate by colors the different solids.
2.- When exporting them to Autodesk Inventor they keep the color of the material assigned.

 

Thank you very much for you attention.

Link to comment
Share on other sites

23 minutes ago, pizarro said:

What happens is that when exporting them, Autodesk inventor does not recognize the colors but the materials.

 

 

 

We need a list of all possible materials.

 

 

Option Explicit

Public Sub test()

    Dim mat As AcadMaterial
    Dim matName As String
    For Each mat In ThisDrawing.Materials
        ''MsgBox mat.Name
        If UCase(mat.Name) = "SITEWORK.PLANTING.GRASS.SHORT" Then
            matName = mat.Name
            Exit For
        End If
    Next
    
    If Len(matName) > 0 Then
        Dim ent As AcadEntity
        For Each ent In ThisDrawing.ModelSpace
            If TypeOf ent Is AcadSolid Then
                ent.Material = matName
            End If
        Next
    End If

End Sub



Sub AddMaterialToLibrary()
    ' This example finds the name of the block associated with a layout.

   Dim material As acadMaterial
   Dim count As Integer
   count = 0
   For Each material In ThisDrawing.Materials
   
        If (StrComp(material.Name, "Bamboo", vbTextCompare) = 0) Then
         MsgBox "The  Bamboo  material Exists"
         count = count + 1
         Exit For
        End If
   Next
      
    If (count < 1) Then
       ThisDrawing.Materials.Add ("Bamboo")
    End If
    MsgBox "Done"
End Sub

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...