Trying to create a custom job to export a wire frame image of a part.

Trying to create a custom job to export a wire frame image of a part.

rpminnovationssd
Participant Participant
1,479 Views
7 Replies
Message 1 of 8

Trying to create a custom job to export a wire frame image of a part.

rpminnovationssd
Participant
Participant

I have code that uses the Inventor API to generate a wireframe image of a part.  Below is a snippet of the code that uses the Inventor.Application object from a stand-alone application the uses the Inventor API.

 

Inventor.Application inventorApplication = null;

Type inventorAppType = System.Type.GetTypeFromProgID("Inventor.Application");
inventorApplication = System.Activator.CreateInstance(inventorAppType) as Inventor.Application;

inventorApplication.DisplayOptions.Show3DIndicator = false;
inventorApplication.ColorSchemes["Presentation"].Activate();
inventorApplication.ColorSchemes.BackgroundType = BackgroundTypeEnum.kOneColorBackgroundType;

...

Document document = inventorApplication.Documents.Open(inventorFile, true);

...

View view = inventorApplication.ActiveView;
                    
int width = view.Width;
int height = view.Height;
if (width > height) view.Width = height;
else if (height > width) view.Height = width;

view.DisplayMode = DisplayModeEnum.kWireframeNoHiddenEdges;
view.ShowGroundReflections = false;
view.ShowGroundShadows = false;
view.ShowAmbientShadows = false;
view.ShowObjectShadows = false;
view.RayTracingQuality = Inventor.RayTracingQualityEnum.kInteractiveRayTracingQuality;

Camera camera = view.Camera;
camera.Fit();
camera.Apply();

Thread.Sleep(1000);
TransientObjects transientObject = inventorApplication.TransientObjects;
Color top = transientObject.CreateColor(255, 255, 255);
Color bottom = transientObject.CreateColor(255, 255, 255);

view.SaveAsBitmap(outputFileName, 175, 175);

document.Close(true);

...

 

Here is a sample image the above code produces.

 

900-1007-230.png

 

I am trying to run this same logic in a custom job.  The custom job uses the Inventor.InventorServer object rather than the Inventor.Application object.  The InventorServer apparently does not have access to "Views".

 

I have an implementation that creates a thumbnail image.  Without access to "View", I do not have access to "DisplayMode" and other properties needed to format the view for a wireframe image.

 

Here is a code snippet of the custom job processor without the wireframe formatting.

 

Inventor.InventorServer inventorServer = context.InventorObject as Inventor.InventorServer;

Inventor.Document inventorDocument = inventorServer.Documents.Open(sourceDocumentPath);


Inventor.PartDocument partDocument = (Inventor.PartDocument)inventorDocument;

// Is there a way to apply these "View" settings to a PartDocument or to the Camera?
//    Inventor.View view = ...
//    view.DisplayMode = Inventor.DisplayModeEnum.kWireframeNoHiddenEdges;
//    view.ShowGroundReflections = false;
//    view.ShowGroundShadows = false;
//    view.ShowAmbientShadows = false;
//    view.ShowObjectShadows = false;
//    view.RayTracingQuality = Inventor.RayTracingQualityEnum.kInteractiveRayTracingQuality;

Inventor.Camera camera = inventorServer.TransientObjects.CreateCamera();
camera.SceneObject = partDocument.ComponentDefinition;
camera.ViewOrientationType = Inventor.ViewOrientationTypeEnum.kIsoTopRightViewOrientation;
camera.Fit();
camera.ApplyWithoutTransition();

Inventor.Color bottomColor = inventorServer.TransientObjects.CreateColor(255, 255, 255, 1); //white

camera.SaveAsBitmap(exportImageFileName, 175, 175, topColor, bottomColor);

inventorDocument.Close(true);

 

Below is a sample image generated from the above snippet.

 

test item pdf update.png

 

Does anyone know how to apply "DisplayMode"- and "RayTracingQuality"-type properties inside a custom job using the Inventor.InventorServer object?

 

Thanks in advance for your help!

0 Likes
Accepted solutions (1)
1,480 Views
7 Replies
Replies (7)
Message 2 of 8

dbyrdJKJBQ
Contributor
Contributor

I believe that what you are looking for is in InventorServer.DisplayOptions

0 Likes
Message 3 of 8

rpminnovationssd
Participant
Participant

I tried these options ...

 

 

inventorServer.DisplayOptions.Show3DIndicator = false;
inventorServer.DisplayOptions.NewWindowDisplayMode = Inventor.DisplayModeEnum.kWireframeNoHiddenEdges;
inventorServer.DisplayOptions.RayTracingQuality = Inventor.RayTracingQualityEnum.kHighRayTracingQuality;
inventorServer.DisplayOptions.NewWindowShowGroundReflections = false;
inventorServer.DisplayOptions.NewWindowShowGroundShadows = false;
inventorServer.DisplayOptions.NewWindowShowAmbientShadows = false;
inventorServer.DisplayOptions.NewWindowShowObjectShadows = false;

inventorServer.ColorSchemes["Presentation"].Activate();
inventorServer.ColorSchemes.BackgroundType = Inventor.BackgroundTypeEnum.kOneColorBackgroundType;

 

It appears something is still missing.

 

test item pdf update.png

 

This is what it looks like with none of the above options.

 

test item pdf update.png

 

Thanks for you help.

0 Likes
Message 4 of 8

rpminnovationssd
Participant
Participant

I also tried several variations of these properties with no success.  They appear to have no effect.

 

inventorServer.DisplayOptions.UseRayTracingForRealisticDisplay = true;
inventorServer.DisplayOptions.DisplaySilhouettes = true;
inventorServer.DisplayOptions.AreTexturesOn = true;
inventorServer.DisplayOptions.SolidLinesForHiddenEdges = true;

 

0 Likes
Message 5 of 8

Markus.Koechl
Autodesk
Autodesk
Accepted solution

InventorServer does not allow any commands that interact with the user or the graphic display. Therefore, views and rendering options are not available in VaultInventorServer. Leverage a full Inventor application for jobs requiring access to full graphics.



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes
Message 6 of 8

rpminnovationssd
Participant
Participant

Thanks for your concise answer.  I suspected that might be the case.

 

I see from this post ...

Solved: Can the JobProcessor create an image of a part/assembly? - Autodesk Community - Vault

 

... that it is possible to launch a full Inventor application instance from the job processor.  Is that the correct approach to take to implement in a job processor job?

 

Dan

0 Likes
Message 7 of 8

Markus.Koechl
Autodesk
Autodesk
It is; scroll down or jump to the solution. The code posted there is still valid (up to 2024).


Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes
Message 8 of 8

rpminnovationssd
Participant
Participant

Thank you very much.

0 Likes