Community
Vault Customization
Share your knowledge, ask questions, and explore popular Vault API, Data Standard, and VBA topics related to programming, creating add-ins, or working with the Vault API.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
rpminnovationssd
225 Views, 7 Replies

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

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!

Labels (3)
7 REPLIES 7
Message 2 of 8

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

Message 3 of 8

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.

Message 4 of 8

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;

 

Message 5 of 8

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
Message 6 of 8

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

Message 7 of 8

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
Message 8 of 8

Thank you very much.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report