API DWG Export layer issues after applying modifications Inventor 2026 .NET 8

API DWG Export layer issues after applying modifications Inventor 2026 .NET 8

speterso
Contributor Contributor
783 Views
12 Replies
Message 1 of 13

API DWG Export layer issues after applying modifications Inventor 2026 .NET 8

speterso
Contributor
Contributor

I am attempting, via a plugin I made, to export  Sheet[1] view and all Sketches relating to the view on Sheet[1].  I open the and apply my changes of the drawing Sheet[1] but when I perform the update to apply my changes and do an export I seem to loose all layer information.   What I change via code is I flip and rotate a flat pattern view, do a conditional tweak to an arrow that was placed in the middle on layer 0 if it is point up vs to the side etc.  That part works fine. 

 

When I do the update and wait for the changes to apply then perform the actions to do the DWG export via code using a generated export ini configuration file things were all exporting on the PROFILE LAYER.  I was able to detect and reapply a BACKROUT LAYER and have that come through  but all other layers just seem to come through as PROFILE LAYER in the exported DWG.  For example the Arrow I mentioned is assigned to 0 LAYER but after export becomes PROFILE LAYER, I have not been able to detect and apply OVERBEND LAYER at all via code and I can't seem to figure out how to handle sketches applied manually to drawing Sheet[1] and were set to BACKROUT LAYER.

 

I am able to use that ini configuration file via a manual export action from inside inventor File->Export DWG and it pulls through all the LAYERS even ones that are not needed.  But that export does not have the modifications I have done programically so that solution to manually perform this fast and easy is not the solution we need.  We are trying to automate the need for the user to make a new sheet perform all the actions of flipping and rotating etc before doing an export into a single ribbon button action.

 

Attached are some text documents of my method and ini file I have so far.  This exports the main PROFILE LAYER and BACKROUT LAYER,  it does not keep the Arrow in the middle on 0 LAYER it gets exported as PROFILE LAYER, it has a line set to OVERBEND LAYER but it does not come through, and I can't seem to figure out how to process the manual sketch on the sheet that was set to BACKROUT and get that exported through as a BACKROUT LAYER.

 

I have tried code to manually set 0 LAYER and OVERBEND all attempts have failed and I removed that code.  I also attempted to handle that manual sketch but failed as well and removed that code.

 

Any help is greatly appreciated, this has been quit a challenging endeavor with Inventor 2026.  I had this all working in Inventor 2023 and .NET Framework 4.8 but upgrading the plugin is proving quit challenging.

 

If more information is needed please just ask.

 

0 Likes
784 Views
12 Replies
Replies (12)
Message 2 of 13

speterso
Contributor
Contributor

I am still struggling to get this working in Inventor 2026 .NET 8.  Any help or advice would be greatly appreciated.   If any more details or code is required please ask I am stumped at this point on how to get this fixed for this version of Inventor.

 

Thanks

0 Likes
Message 3 of 13

speterso
Contributor
Contributor

So been brain storming other workarounds.  Would the following be any better process even though it is not as easy as a single ribbon button press like I had it working in Inventor 2024 and earlier using .NET framework 4.8?

 

Since I can get the model to export manually with all layers via Inventor 2026 File->Export->Export to DWG and use my configured ini as I supplied.  This gives me the DWG just no rotations and flipping and other manipulations and no manually added IDW sketches.   I then create an AutoCAD 2026 plugin that can be run via a ribbon button click that performs the flip, rotate and other orientations and then perform a save action.

 

This would still not handle the manual sketches added to the IDW and set to BACKROUT.  ChatGPT suggested a dirty workaround is to set these new IDW sketches to wrong linewieghts and some other layer and ID it with a name or color or something and hope my Export to DWG picks these sketchs up as added geometry and export it as well.   Then in the Autocad plugin I would then look for these added sketch exports by those wrong keys and correct them to correct lineweight and BACKROUT layer somehow.

 

I am pressured with putting time against this and having it fail so would like to get confirmation on this first.  This is not the best solution and it adds extra steps to what engineers use to do but it does reduce work and still automates some of the manual time consuming redundant steps engineers always do and have a chance of missing a step.  

 

The best solution still is to come up with a Inventor 2026 .NET 8 single button export solution that once worked in Inventor 2024 and prior via .NET Framework 4.8 but I just can't get anything working myself and think maybe it is because Inventors 2026 .NET 8 API just isn't mature yet to do many of the harder tasks the prior API use to support.

0 Likes
Message 4 of 13

speterso
Contributor
Contributor

Still looking for any help on how I could get this working.  If more info is needed to assist please just ask.

 

Thanks

0 Likes
Message 5 of 13

jnowel
Collaborator
Collaborator

Just a disclaimer, not really that familiar with the language so this might be a long shot.
jnowel_1-1770652373931.png

In iLogic, this portion uses the "nvmOptions.Value"; using "nvmOptions.Add" will result to an error (not sure if in this language, that is OK)
Also, I would assume you are using an existing "ACAD2004SaveAs.ini" instead of the attached "Export_ini.txt".

Message 6 of 13

speterso
Contributor
Contributor

Thanks for the reply,  I attempted to use the "nvmOptions.Value" suggestion but I needed to apply a late binding approach to get it to work ie.

 

NameValueMap nvmOptions = tObjs.CreateNameValueMap();
String IniFile = "C:\\ProgramData\\Autodesk\\AddIns\\AmeriCladRouterTurretAddin\\ACAD2004SaveAs.ini";

dynamic d = nvmOptions;
d.Value["Export_Acad_IniFile"] = IniFile;

 

This has done something different so might be onto something here.   Instead of the Arrow being on PROFILE Layer now on export it is on a HiddenLayer, which is progress.  

 

OVERBEND seems to come through at BACKROUT now which is good it comes through but it isn't the right layer.  I will try some more things to see why the OVERBEND layer is behaving weird from before Inventor 2026 and .Net 8.

 

Thank You for your assistance, it does help I would have not thought to set the value like this, I would have thought the Add would have created it but must have required a late binding.

 

If you have any idea why an OVERBEND would have issues exporting I would be interested in  hearing your ideas.

 

Again Thank you for your help.

0 Likes
Message 7 of 13

jnowel
Collaborator
Collaborator

If I recall correctly, in iLogic, even with an empty IniFile (i.e. not found), the DWG export can proceed.

It will use a "default" or the "last used" INI file. can't recall which one.


With that, can you change the DWG version to something else, say, from ACAD 2004 to ACAD 2010

This is just to check if the INI file is indeed found and used for export, i.e. the output DWG should now be in ACAD 2010
How to find the format of a DWG or which version of AutoCAD was used to save it

AC1018 - DWG AutoCAD 2004/2005/2006
AC1021 - DWG AutoCAD 2007/2008/2009
AC1024 - DWG AutoCAD 2010/2011/2012


Also, can you provide test files? so that it is easier to imagine the input/output, the expected vs current results)

0 Likes
Message 8 of 13

speterso
Contributor
Contributor

Sure thing, I  attached the IPT and IDW examples, the IDW has the layers assigned.  The important layers are 0, PROFILE, BACKROUT and OVERBEND.   We only work with the Flat Layout sheet in the IDW, the projections sheet can be ignored.

 

I also supplied the current output DWG with my rotation and flip logic applied.

 

In the IDW you can see I have the right inside bend set to OVERBEND Layer and in the DWG I supplied you can see it come through as BACKROUT.

 

If you need expanded code parts let me know.

0 Likes
Message 9 of 13

jnowel
Collaborator
Collaborator

I tried using the attached INI file just to see how it exports and out of the box, I encounter an issue.

Is this file existing in your end?

AUTOCAD TEMPLATE=C:\Temp\seed.dwg

To proceed, i just left it as blank like

AUTOCAD TEMPLATE=

so using my own DWG export (in iLogic), and the modified INI file, I got this export.

jnowel_1-1770740450382.png 

edit: i made a wrong copy in what i changed in the INI file

0 Likes
Message 10 of 13

speterso
Contributor
Contributor

yes I have a seed.dwg file,  I never needed it before though.  It is basically a blank ACAD dwg.  I attached it below.

 

Did you do File->Export DWG from Inventor file menu?  This works but doesn't do any of my code logic, as I rotate and flip the sheet for use by machines.  I only see the export fail when doing the export via code, I find it weird also that it works via manual export process but code causes issues.

 

 

0 Likes
Message 11 of 13

jnowel
Collaborator
Collaborator

I exported using iLogic DWG Export (not the File-> Export DWG from File Menu)
I'm just checking how your INI file outputs.

I'll try replicating/editing your code in iLogic tomorrow and see how it goes.
I don't really do C# (as mentioned in my disclaimer) but curious to see how it runs in iLogic.

And also, maybe somebody can also jump in since we have some test files now

Message 12 of 13

jnowel
Collaborator
Collaborator

OVERBEND seems to come through at BACKROUT now which is good it comes through but it isn't the right layer.  I will try some more things to see why the OVERBEND layer is behaving weird from before Inventor 2026 and .Net 8


Btw, just to confirm you want the "bend ups" to be OVERBEND and "bend downs" to be BACKROUT?
I think this is easily solved by updating your object defaults.
In the IDW provided earlier, both layers are set to BACKROUT

jnowel_0-1770743637768.png

 


Instead of the Arrow being on PROFILE Layer now on export it is on a HiddenLayer, which is progress.  


I think this is due to wrong naming in the feature tree. in your code your kinda expecting some Sketch with "GRAIN" or "ARROW" which is absent in the test IPT file.
On the test file, the Hidden Layer is expected since the current arrow lines are from the embossed features. Flipping the view puts that emboss side on the bottom turning them into hidden lines.
Maybe set the Object Defaults to 0 (maybe you need to check the other hidden edges if needed to be changed as well)

jnowel_1-1770744163114.png

0 Likes
Message 13 of 13

speterso
Contributor
Contributor

I am having the client double check those layer settings and verify they are correct or should be changed to your suggestions.  Won't hear back until tomorrow most likely.

0 Likes