• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

coloring lines table inventor

  • Thread starter Thread starter cavallo
  • Start date Start date

cavallo

Guest
Hello everyone
I need to make boards with colored lines. I currently proceed by selecting the components from browsers and setting the color from the properties, using the right button. But if I have a component in multiple views I have to color them all, even using the filter is a little long....is there a faster way? I don't know how to use ilogic.
would be the top set something in the 3d components and find the colored lines at the table, but I don't know if you can do it. . .
thanks to all in advance
 
centuries ago I found and adapted to my way of working this macro:
you select a design view and recolor the lines "copying" the pattern color, if it is different from the standard, otherwise it leaves it black. the problem is that for big assemblies it takes so much, so to use with caution and, if the axieme is full, be ready to long waits.
Anyway (to me) it works.
Code:
public sub associacolore()
   ' get the active drawing document.
   dim drawdoc as drawingdocument
   set drawdoc = thisapplication.activedocument

   ' have the user select a drawing view.
   dim drawview as drawingview
   set drawview = thisapplication.commandmanager.pick( _
                  kdrawingviewfilter, "select a drawing view.")

   dim docdesc as documentdescriptor
   set docdesc = drawview.referenceddocumentdescriptor
 
   ' verify that the selected drawing view is of an assembly.
   if docdesc.referenceddocumenttype <> kassemblydocumentobject then
      msgbox "the selected view must be of an assembly."
      exit sub
   end if

   ' get the component definition for the assembly.
   dim asmdef as assemblycomponentdefinition
   set asmdef = docdesc.referenceddocument.componentdefinition

   ' process the occurrences, wrapping it in a transaction so the
   ' entire process can be undone with a single undo operation.
   dim trans as transaction
   set trans = thisapplication.transactionmanager.starttransaction( _
                               drawdoc, "change drawing view color")

   ' call the recursive function that does all the work.
   call processassemblycolor(drawview, asmdef.occurrences)
   trans.end
end sub


private sub processassemblycolor(drawview as drawingview, _
                                 occurrences as componentoccurrences)
   ' iterate through the current collection of occurrences.
   dim occ as componentoccurrence
   dim opart as partdocument
  
   for each occ in occurrences
    if occ.suppressed = false then
      ' check to see if this occurrence is a part or assembly.
      if occ.definitiondocumenttype = kpartdocumentobject then
         ' ** it's a part so process the color.
        
         ' get the render style of the occurrence.
         dim color as renderstyle
         dim sourcetype as stylesourcetypeenum
         set color = occ.getrenderstyle(sourcetype)
        
        dim materialcolor as renderstyle
        set opart = occ.definition.document
        
        dim omaterial as materialasset
        set omaterial = opart.activematerial
        
        
        
        'set materialcolor = omaterial.appearanceasset.name
        debug.print opart.displayname
        debug.print "colore attivo:", opart.activeappearance.name
        debug.print "colore materiale:", omaterial.appearanceasset.name
'        if opart.activeappearance.name <> omaterial.appearanceasset.name then
        if occ.appearance.name <> omaterial.appearanceasset.name then
             ' get the transientsobjects object to use later.
             dim transobjs as transientobjects
             set transobjs = thisapplication.transientobjects
    
             ' verify that a layer exists for this color.
             dim layers as layersenumerator
             set layers = drawview.parent.parent.stylesmanager.layers
    
             dim drawdoc as drawingdocument
             set drawdoc = drawview.parent.parent
    
             on error resume next
             dim colorlayer as layer
             set colorlayer = layers.item(color.name)

             if err.number <> 0 then
                on error goto 0
                ' get the diffuse color for the render style.
                dim red as byte
                dim green as byte
                dim blue as byte
    
                ' create a color object that is the diffuse color.
                call color.getdiffusecolor(red, green, blue)
                dim newcolor as color
                set newcolor = transobjs.createcolor(red, green, blue)
    
                ' copy an arbitrary layer giving it the name
                ' of the render style.
                set colorlayer = layers.item(1).copy(color.name)
    
                ' set the attributes of the layer to use the color,
                ' have a solid line type, and a specific width.
                colorlayer.color = newcolor
                colorlayer.linetype = kcontinuouslinetype
                colorlayer.lineweight = 0.02
             end if
             on error goto 0
    
             ' get all of the curves associated with this occurrence.
             on error resume next
             dim drawcurves as drawingcurvesenumerator
             set drawcurves = drawview.drawingcurves(occ)
             if err.number = 0 then
                on error goto 0
    
                ' create an empty collection.
                dim objcoll as objectcollection
                set objcoll = transobjs.createobjectcollection()
    
                ' add the curve segments to the collection.
                dim drawcurve as drawingcurve
                for each drawcurve in drawcurves
                   dim segment as drawingcurvesegment
                   for each segment in drawcurve.segments
                      objcoll.add segment
                   next
                next
    
                ' change the layer of all of the segments.
                call drawview.parent.changelayer(objcoll, colorlayer)
             end if
             on error goto 0
          else
        
         ' it's an assembly so process its contents.
         if occ.suboccurrences.count > 0 then
            call processassemblycolor(drawview, occ.suboccurrences)
        end if
      end if
    end if
    end if
   next
end sub
 
is it not possible to associate a table layer with a 3d property?
If I created a property on the 3d and associate the coloring elements, then I change only the color to the layer.. .
A bit like autocad...
 
for those who use it, can you select fields from the 3d or recover only the graphic lines of the table?
Thank you.
 

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
Back
Top