Controlling Layer color in Flat Pattern Export

Controlling Layer color in Flat Pattern Export

w.pepping
Advocate Advocate
1,243 Views
3 Replies
Message 1 of 4

Controlling Layer color in Flat Pattern Export

w.pepping
Advocate
Advocate

I use attributes to overide some layers in the DXF flat pattern export.

I have used this article to do this.

If I use 'Save Copy As' in the flat pattern environment, it is possible to change the color of the 'CustomLayer', but this is not stored anywhere.

Is it also possible to overide the color by the API? 

Get control of your sheet metal files.
Download the app from matprop.com
0 Likes
Accepted solutions (1)
1,244 Views
3 Replies
Replies (3)
Message 2 of 4

JelteDeJong
Mentor
Mentor

In the article that you refere to a variable "sOut" is used to define the format of the Dxf. That variable "sOut" can be used to also set colors for layers. have a look at this forum post:

https://forums.autodesk.com/t5/inventor-customization/export-into-quot-dxf-quot-the-flat-pattern-par... 

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 3 of 4

w.pepping
Advocate
Advocate

Hallo Jelte,

thanks for your answer. 

This is not exactly what I need.

I have overruled for some features the "InteriorProfilesLayer" by using attributes.

Now I have a new layer "CustomLayer".

How can I find this in the sOut?

Get control of your sheet metal files.
Download the app from matprop.com
0 Likes
Message 4 of 4

JelteDeJong
Mentor
Mentor
Accepted solution

i could not find a solution with the inventor API. But dxf files are txt files and there not difficult to change. you can try this iLogic rule.

 

Dim filename = "D:\forum\flat.dxf"
Dim LayerName = "MYLAYER"
Dim color = 100
' colors found on: http://data.tessel.pl/manuals/HyperDoc/content/bk08ch01s06.html

'create dxf file
Dim oDoc As PartDocument = ThisApplication.ActiveDocument
Dim oDataIO As DataIO = oDoc.ComponentDefinition.DataIO
Dim sOut As String = "FLAT PATTERN DXF?AcadVersion=R12"
oDataIO.WriteDataToFile(sOut, filename)

'change dxf
Dim lines() As String = IO.File.ReadAllLines(filename)
For i = 1 To lines.Count - 10
    If (lines(i) = "LAYER" And
            lines(i + 1) = "  2" And
            lines(i + 2) = LayerName
            ) Then
        lines(i + 6) = "     " & color
    End If

Next
IO.File.WriteAllLines(filename, lines)

 

 You need to change the 3 variable in the top of the code.

The "LayerName" needs to be exact the name that you used in the attribute.

The "color" needs to be an integer between 1 and 255.  on this side i found a nice color map and here a conversion table

Last but not least. Normally i would not advice to edit files directly like this, there for this disclamer: I did not test this extensively. You will need to that before using it in production.

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes