Jump to content
pizarro

Assign materials

Recommended Posts

pizarro

some lisp to assign materials to different 3D elements automatically and randomly.

Share this post


Link to post
Share on other sites
BIGAL

I dont do much with 3d but way to little information provided.

 

Object types 

List of materials 5, 7, 25 ?

 

Share this post


Link to post
Share on other sites
pizarro

Elements 3D are solids.

Share this post


Link to post
Share on other sites
maratovich
49 minutes ago, pizarro said:

Elements 3D are solids.

what is your ultimate goal?

Share this post


Link to post
Share on other sites
pizarro

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.

Share this post


Link to post
Share on other sites
pizarro

Another option would be to assign materials for each layer

 

Share this post


Link to post
Share on other sites
maratovich

Why the material? Maybe you need to change the color?

Share this post


Link to post
Share on other sites
pizarro

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

Share this post


Link to post
Share on other sites
maratovich
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

 

Share this post


Link to post
Share on other sites
pizarro

The suggested list is the following:
Steel
Wood
Concrete
Aluminum
Copper
Bronze
Stainless steel
Foundry
Plastic
Glass...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×