Unable to create flat pattern

Unable to create flat pattern

JelteDeJong
Mentor Mentor
401 Views
1 Reply
Message 1 of 2

Unable to create flat pattern

JelteDeJong
Mentor
Mentor

Im writing a addon in c#. This addon needs to create a drawing from a part file that is active when i run the addon. It needs to create a view from a flat pattern in a idw.

below you find the relevant code. Most code is copyed from the help file and converted to c#.

 

Document oDoc = inv.ActiveDocument;// <-- assume this is a part document

string templatePath = inv.FileManager.GetTemplateFile(DocumentTypeEnum.kDrawingDocumentObject);

DrawingDocument oDrawDoc = (DrawingDocument)inv.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject, templatePath);

Sheet oSheet = oDrawDoc.ActiveSheet;

NameValueMap oBaseViewOptions = inv.TransientObjects.CreateNameValueMap();
oBaseViewOptions.Add("SheetMetalFoldedModel", false); // <- if this is set to "true" it will work

TransientGeometry oTG = inv.TransientGeometry;
Point2d insertPoint = oTG.CreatePoint2d(15, 12);
DrawingView oFrontView = oSheet.DrawingViews.AddBaseView(
    (_Document)oDoc, insertPoint, 
    1, 
    ViewOrientationTypeEnum.kCurrentViewOrientation,
    DrawingViewStyleEnum.kHiddenLineDrawingViewStyle, 
    "", 
    null, 
    oBaseViewOptions);

The line "oBaseViewOptions.Add("SheetMetalFoldedModel", false);" is the option that tells inventor to create a flat pattern. This option only fails if i set it to "false". (if i set it to "true" the code runs with out any problems but i dont get a flat pattern.)

 

 

the error message is:
System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

 

Can some one tell me what i should do different?

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
Accepted solutions (1)
402 Views
1 Reply
Reply (1)
Message 2 of 2

JelteDeJong
Mentor
Mentor
Accepted solution

I found the solution.  the "ViewOrientation" may not be set to "ViewOrientationTypeEnum.kCurrentViewOrientation". It works if i set it to "ViewOrientationTypeEnum.kDefaultViewOrientation"

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