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

assignment coloring dashes to inventor materials

  • Thread starter Thread starter turyllo
  • Start date Start date

turyllo

Guest
hi, it is clear that in inventor it is possible to assign a certain style of deduction to each type of different material, but if you want to assign also the color of the different dash for each different material you know how to do it?
i searched in layers but the assignment is unique for the restraint who can help me?
it is clear that individually i can change it with the dx change and color change button but i want to configure the style so that automatically in addition to associating the type of restraint to the material also associates me with a specific color to the dash.
thank you.
 
Hi.
I don't think it's manageable, option I propose you create the layers you want with the colors you want and then hand-check them, but it depends on the amount of items you select.
 
I think it is the same reasoning for the lines that represent the perimeter of an object in the table, by default it is associated with the visible layer but can be automatically associated with another layer?
It is clear that in a manual way you can change everything in the views of the masses on the table but I wanted an automatic customization of the type of line according to the material.
 
Hi, it is clear that in inventor it is possible to assign a certain style of deduction to each type of different material, but if you want to assign also the color of the different dash for each different material you know how to do it?

Thank you.
ilogic rule of below assigns layers with the same name as materials. . .
Maybe if the template already contains layers with predefined colors (most common materials)... it could work.
Code:
sub main
    drawdoc = trycast(thisdoc.document, drawingdocument)
    if (drawdoc is nothing) then
       messagebox.show("this rule can only be run in a drawing,", "ilogic")
       return
    end if
    changelayerofoccurrencecurves()
end sub

private drawdoc as drawingdocument

public sub changelayerofoccurrencecurves()
    ' process the occurrences, wrapping it in a transaction so the
    ' entire process can be undone with a single undo operation.
    dim trans as transaction
    trans = thisapplication.transactionmanager.starttransaction(drawdoc, "drawing layers by materials")
    try
        for each dsheet as sheet in drawdoc.sheets
            for each drawview as drawingview in dsheet.drawingviews
                ' call the recursive function that does all the work.
                dim docdesc as documentdescriptor
                docdesc = drawview.referenceddocumentdescriptor
                if (docdesc is nothing) then continue for
                if (docdesc.referenceddocumenttype = documenttypeenum.kassemblydocumentobject) then
                    dim asmdef as assemblycomponentdefinition
                    asmdef = docdesc.referenceddocument.componentdefinition
                    processoccurrences(drawview, asmdef.occurrences)
                elseif (docdesc.referenceddocumenttype = documenttypeenum.kpartdocumentobject) then
                    dim partdoc as partdocument = trycast(docdesc.referenceddocument, partdocument)
                    if (partdoc is nothing) then continue for
                    processpart(drawview, partdoc)
                end if
            next
        next
    catch ex as exception
        trans.abort()
        throw ex
    end try
    trans.end()
end sub

sub processoccurrences(byval drawview as drawingview, byval occurrences as componentoccurrences)
    ' iterate through the current collection of occurrences.
    dim occ as componentoccurrence
    for each occ in occurrences
        if (occ.suppressed) then continue for
        if (occ.definition is nothing) then continue for
        if (occ.referenceddocumentdescriptor is nothing) then continue for
        if (occ.referenceddocumentdescriptor.referencemissing) then continue for
        ' check to see if this occurrence is a part or assembly.
        if occ.definitiondocumenttype = documenttypeenum.kpartdocumentobject then
            ' ** it's a part so get the material
            dim subdoc as document = occ.definition.document
            if (subdoc is nothing) then continue for
            dim partdoc as partdocument = subdoc
            dim newlayer as layer = getorcreatelayer(partdoc)

            ' get all of the curves associated with this occurrence.
            on error resume next
            dim drawcurves as drawingcurvesenumerator
            drawcurves = drawview.drawingcurves(occ)
            if err.number = 0 then
                on error goto 0
                setdrawingcurveslayer(drawcurves, drawview, newlayer)
            end if
            on error goto 0
        else
            ' it's an assembly so process its contents.
            call processoccurrences(drawview, occ.suboccurrences)
        end if
    next
end sub

sub processpart(byval drawview as drawingview, byval partdoc as partdocument)
    dim newlayer as layer = getorcreatelayer(partdoc)
    on error resume next
    dim drawcurves as drawingcurvesenumerator
    drawcurves = drawview.drawingcurves()
    if err.number = 0 then
        on error goto 0
        setdrawingcurveslayer(drawcurves, drawview, newlayer)
    end if
end sub

function getorcreatelayer(byval partdoc as partdocument) as layer
    dim materialname = partdoc.componentdefinition.material.name

    ' verify that a layer exists for this material.
    dim layers as layersenumerator
    layers = drawdoc.stylesmanager.layers

    on error resume next
    dim newlayer as layer
    newlayer = layers.item(materialname)

    if err.number <> 0 then
        on error goto 0

        ' copy an arbitrary layer giving it the name
        ' of the material.
        newlayer = layers.item(1).copy(materialname)

        ' set the attributes of the layer to use the color,
        ' have a solid line type, and a specific width.
        '                    newlayer.color = newcolor
        newlayer.linetype = linetypeenum.kcontinuouslinetype
        'newlayer.lineweight = 0.02
    end if
    on error goto 0
    return newlayer
end function

sub setdrawingcurveslayer(byval drawcurves as drawingcurvesenumerator, byval drawview as drawingview, byval newlayer as layer)
    ' create an empty collection.
    dim objcoll as objectcollection
    objcoll = thisapplication.transientobjects.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.
    drawview.parent.changelayer(objcoll, newlayer)
end sub
 
ilogic rule of below assigns layers with the same name as materials. . .
Maybe if the template already contains layers with predefined colors (most common materials)... it could work.
Code:
sub main
    drawdoc = trycast(thisdoc.document, drawingdocument)
    if (drawdoc is nothing) then
       messagebox.show("this rule can only be run in a drawing,", "ilogic")
       return
    end if
    changelayerofoccurrencecurves()
end sub

private drawdoc as drawingdocument

public sub changelayerofoccurrencecurves()
    ' process the occurrences, wrapping it in a transaction so the
    ' entire process can be undone with a single undo operation.
    dim trans as transaction
    trans = thisapplication.transactionmanager.starttransaction(drawdoc, "drawing layers by materials")
    try
        for each dsheet as sheet in drawdoc.sheets
            for each drawview as drawingview in dsheet.drawingviews
                ' call the recursive function that does all the work.
                dim docdesc as documentdescriptor
                docdesc = drawview.referenceddocumentdescriptor
                if (docdesc is nothing) then continue for
                if (docdesc.referenceddocumenttype = documenttypeenum.kassemblydocumentobject) then
                    dim asmdef as assemblycomponentdefinition
                    asmdef = docdesc.referenceddocument.componentdefinition
                    processoccurrences(drawview, asmdef.occurrences)
                elseif (docdesc.referenceddocumenttype = documenttypeenum.kpartdocumentobject) then
                    dim partdoc as partdocument = trycast(docdesc.referenceddocument, partdocument)
                    if (partdoc is nothing) then continue for
                    processpart(drawview, partdoc)
                end if
            next
        next
    catch ex as exception
        trans.abort()
        throw ex
    end try
    trans.end()
end sub

sub processoccurrences(byval drawview as drawingview, byval occurrences as componentoccurrences)
    ' iterate through the current collection of occurrences.
    dim occ as componentoccurrence
    for each occ in occurrences
        if (occ.suppressed) then continue for
        if (occ.definition is nothing) then continue for
        if (occ.referenceddocumentdescriptor is nothing) then continue for
        if (occ.referenceddocumentdescriptor.referencemissing) then continue for
        ' check to see if this occurrence is a part or assembly.
        if occ.definitiondocumenttype = documenttypeenum.kpartdocumentobject then
            ' ** it's a part so get the material
            dim subdoc as document = occ.definition.document
            if (subdoc is nothing) then continue for
            dim partdoc as partdocument = subdoc
            dim newlayer as layer = getorcreatelayer(partdoc)

            ' get all of the curves associated with this occurrence.
            on error resume next
            dim drawcurves as drawingcurvesenumerator
            drawcurves = drawview.drawingcurves(occ)
            if err.number = 0 then
                on error goto 0
                setdrawingcurveslayer(drawcurves, drawview, newlayer)
            end if
            on error goto 0
        else
            ' it's an assembly so process its contents.
            call processoccurrences(drawview, occ.suboccurrences)
        end if
    next
end sub

sub processpart(byval drawview as drawingview, byval partdoc as partdocument)
    dim newlayer as layer = getorcreatelayer(partdoc)
    on error resume next
    dim drawcurves as drawingcurvesenumerator
    drawcurves = drawview.drawingcurves()
    if err.number = 0 then
        on error goto 0
        setdrawingcurveslayer(drawcurves, drawview, newlayer)
    end if
end sub

function getorcreatelayer(byval partdoc as partdocument) as layer
    dim materialname = partdoc.componentdefinition.material.name

    ' verify that a layer exists for this material.
    dim layers as layersenumerator
    layers = drawdoc.stylesmanager.layers

    on error resume next
    dim newlayer as layer
    newlayer = layers.item(materialname)

    if err.number <> 0 then
        on error goto 0

        ' copy an arbitrary layer giving it the name
        ' of the material.
        newlayer = layers.item(1).copy(materialname)

        ' set the attributes of the layer to use the color,
        ' have a solid line type, and a specific width.
        '                    newlayer.color = newcolor
        newlayer.linetype = linetypeenum.kcontinuouslinetype
        'newlayer.lineweight = 0.02
    end if
    on error goto 0
    return newlayer
end function

sub setdrawingcurveslayer(byval drawcurves as drawingcurvesenumerator, byval drawview as drawingview, byval newlayer as layer)
    ' create an empty collection.
    dim objcoll as objectcollection
    objcoll = thisapplication.transientobjects.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.
    drawview.parent.changelayer(objcoll, newlayer)
end sub
thanks to the help but could you be clearer on how to use the rule?
Thank you.
 

Forum statistics

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

Members online

No members online now.
Back
Top