How can i add a DesignViewRepresentation to the standard DrawingView?

Anonymous

How can i add a DesignViewRepresentation to the standard DrawingView?

Anonymous
Not applicable

How can i ADD the DesignViewRepresentation to a Drawingview?

if i use my code, the Designviewrepresentation replaces the content in the Standard DrawingView instead of adding it.

 

RepresentationsManager dViewRepMgr = assemblyCompDef.RepresentationsManager;
DesignViewRepresentation dViewRep = dViewRepMgr.DesignViewRepresentations[1];

 

// Here the view is replaces instead of added to the standard view:

// i tried this 3 variants:
oView.SetDesignViewRepresentation(dViewRep.Name);
oOccurrence.SetDesignViewRepresentation(dViewRep.Name);

ActiveSheet.DrawingViews.AddOverlayView(oView, null, dViewRep.Name, false,

DrawingViewStyleEnum.kFromBaseDrawingViewStyle, false);

 

Thank you for your help

0 Likes
Reply
519 Views
5 Replies
Replies (5)

sundars
Autodesk
Autodesk

Hi @Anonymous 

 

oView.SetDesignViewRepresentation(string viewrepname) should apply the given design view properties to the drawing view. This should only show/hide components, apply color/texture etc. It will modify the contents of the drawing view. It should not replace the drawing view. 

 

Can you elaborate or show some pictures of the before and after?

-shiva

Shiva Sundaram
Inventor Development

Anonymous
Not applicable

Hello Sundars, thank you for your reply.

 

sorry if i habe not clearly described the problem.

 

yes. the method setDesignViewRepresentation replaces the content of the drawing view. it does not replace the drawing view itself.

What i whant is an overlay to the existing content of the drawing view.

So i can see the normal status of the object, lets say a car with straight wheels in top-down view and as an overlay i have to display the turned wheels too.

 

Sorry for my bad english.

Do you  know how this is possible.

In the UI its very easy, but i am not able to do that in the api.

unfortunately i can not provide you with a screenshot, because this is a confidential project.

 

Thanks in advance

 

0 Likes

sundars
Autodesk
Autodesk

Hi @Anonymous 

 

No worries. No need to apologize. I understand your problem now. 

 

To add an Overlay view, you can try  the "AddOverlayView" method.

For this,

1. create a base view first

2. then create the overlay view next

3. supply the name of the positional representation which shows the turned wheels

4. That should create an overlay view for you.

 

Let me know if you have any trouble.

 

Thanks

-shiva

----------------------------------------------------------------------

DrawingViews.AddOverlayView Method

Parent Object: DrawingViews

Description

Method that creates an overlay drawing view.

Syntax

DrawingViews.AddOverlayView( ParentView As DrawingView, PositionalRepresentation As String, DesignViewRepresentation As String, DesignViewAssociative As Boolean, ViewStyle As DrawingViewStyleEnum, [ShowLabel] As Boolean, [Name] As String ) As DrawingView

Shiva Sundaram
Inventor Development

Anonymous
Not applicable

Hello Sundars,

 

thank  you again for your help.

unfortunately my Dataprep Team provided me only a DesignviewRepresentation, no PositionalRepresentation.

 

The Method "AddOverlayView" needs two Strings, one for PositionalRep, one for DesignViewRep.

Whatever i try, im getting the error "wrong parameter", i assume, because i dont have a PositionalRepresentation

The DrawingViews with 4 Perspectives (Topdown, Front, Rear, Side) already exists as baseviews, i dont have to create it by code.

here is what i tried:


DrawingDocument oDoc = (DrawingDocument)inventorApp.ActiveDocument;
Sheet ActiveSheet = oDoc.ActiveSheet;
DrawingView oView = ActiveSheet.DrawingViews[drawingNumber];
AssemblyDocument oAssyDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument;
AssemblyComponentDefinition assemblyCompDef = (AssemblyComponentDefinition)oAssyDoc.ComponentDefinition;

RepresentationsManager dViewRepMgr = assemblyCompDef.RepresentationsManager;

PositionalRepresentation posRep = dViewRepMgr.PositionalRepresentations[1];
DesignViewRepresentation dViewRep = dViewRepMgr.DesignViewRepresentations[i + 1];
try
{
ActiveSheet.DrawingViews.AddOverlayView(oView.ParentView, posRep.Name, dViewRep.Name, false, DrawingViewStyleEnum.kFromBaseDrawingViewStyle, false);
}
catch (Exception e) {Log(e.Message)}
try
{
ActiveSheet.DrawingViews.AddOverlayView(oView.ParentView, "Master", dViewRep.Name, false, DrawingViewStyleEnum.kFromBaseDrawingViewStyle, false);
}
catch (Exception e) {Log(e.Message)}
try
{
ActiveSheet.DrawingViews.AddOverlayView(oView.ParentView, "", dViewRep.Name, false, DrawingViewStyleEnum.kFromBaseDrawingViewStyle, false);
}
catch (Exception e) {Log(e.Message)}

 

Im  a little stuck at the moment 😉

 

 

0 Likes

sundars
Autodesk
Autodesk

Hi Stefan,

 

I have attached a simple posrep assembly and a vba to demonstrate the creation. The posrep and dv names are hard-coded in the script but you can very well use the same logic in your vba script do find the correct string name and supply it to the AddOverlayView cmd.

 

The dataset is created in Inventor 2021. Try it out and then compare it against your program and dataset. 

 

So, if you do not have a posrep in your assembly you can use "Master" 

In your script you have oView.ParentView. If oView is a base view, then oView.ParentView would be incorrect because base view is the parent. you may try changing that parameter.

 

ActiveSheet.DrawingViews.AddOverlayView(oView.ParentView, posRep.Name, dViewRep.Name, false, DrawingViewStyleEnum.kFromBaseDrawingViewStyle, false);

 

I am not able to compile your script. But you can try to use my working script and see if that works for you compare where you are going wrong in your script.

 

Thanks and good luck!

-shiva

 

 

Shiva Sundaram
Inventor Development