Message 1 of 6

Not applicable
01-27-2017
08:13 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
hi friends,
I am trying to make a drawing of an assembly using iLogic, my efforts to make base view and side/top views were successful
but when i try to get section view i get nothing except an error message .
with this code runing i get base view and top view in buttom of that but not section view.
i have to mention that this code is based on some parameters that i have in my design. such as "Height" and "Length". also the function " StructureView" just suppresses some parts to get internal parts in view.
I'm using the code below:
'RDS 'RDS dims: Imports Inventor.ViewOrientationTypeEnum Imports Inventor.DrawingViewStyleEnum Imports Inventor.DrawingViewTyoeEnum Imports Inventor.PointIntentEnum Imports Inventor.DimensionTypeEnum Imports Inventor.DrawingCurveSegmentEnum Imports Inventor.DrawingCurveEnum Imports Inventor.CurveTypeEnum Sub Main() 'RDS dims in mm Dim sheetheight As Integer = 297 'sheet size A3 Dim sheetwidth As Integer = 420 'sheet size A3 Dim tableheight As Integer = 51 'type A Dim tablewidth As Integer = 160 'type A Dim borderoffset As Integer = 10 'rounded up Dim viewdis As Integer =10 'selective Dim baseviewheight As Integer = Height Dim baseviewwidth As Integer = Length Dim fitspaceheight As Integer = sheetheight -tableheight - (2*borderoffset)-(3*viewdis) Dim fitspacewidth As Integer = sheetwidth- (2*borderoffset)-(2*viesdis)-50 Dim Hscale As Double = Height/fitspaceheight Dim Wscale As Double = Length/fitspacewidth Dim scale As Double If Wscale> Hscale Then scale=Wscale Else If Hscale>Wscale Then scale=Hscale Else If Hscale=Wscale Then scale=Hscale End If 'RDS ends dim% AskCreateDrawing = MessageBox.Show("if you would like to create a STRUCTURE drawing from this view, please hit YES and then fill up comming filds (RDS) ", "Sajiran-Beta Partitioning System",MessageBoxButtons.YesNo,MessageBoxIcon.Question) 'RDS asks for plot: If AskCreateDrawing = vbYes Then 'RDS asks for project name & code and also view name iProperties.Value("Project", "Project") = InputBox("Enter Project Name:", "Sajiran-Beta Partitioning System", "Sajiran") iProperties.Value("project", "Stock Number") = InputBox("Enter Project Code:", "Sajiran-Beta Partitioning System", "1234") iProperties.Value("Status", "Status") = InputBox("Enter View Name:", "Sajiran-Beta Partitioning System", "View 1") 'RDS alter to structure Structureview (True) 'RDS inserts calculated scale into rule: Dim DrawingViewScale As Double DrawingViewScale = 1/scale Dim AssemblyDocName As String AssemblyDocName = ThisDoc.FileName(False) 'without extension Assem_DrawingDoc = CreateDrawing_PlaceViews (AssemblyDocName, DrawingViewScale, "Top_Section", True, oBaseView, oRightSideView, oProjectView, oView4) 'RDS Save As oDrawingDoc (Path and File Name) : oPartPath = ThisDoc.Path oPartPathLength = Len(oPartPath) oDrawingPath = Left(oPartPath, oPartPathLength - 7) oDrawingDoc = oDrawingPath & "\" & AssemblyDocName & ".idw" Assem_DrawingDoc.SaveAs(oDrawingDoc, False) 'RDS Close the Template Drawing: Assem_DrawingDoc.Close(True) 'RDS Open the Newly Saved Drawing: DrawingDoc = ThisApplication.Documents.Open(oDrawingDoc, True) Structureview (False) End If End Sub 'RDS dims function: Function CreateDrawing_PlaceViews (PartNumber As String, DrawingViewScale As Double, ViewsToPlace As String, AssemblyDrawing As Boolean, ByRef oBaseView As DrawingView, ByRef oView2 As DrawingView, ByRef oView3 As DrawingView, ByRef oView4 As SectionDrawingView) 'RDS dims: Dim oDrawDoc As DrawingDocument Dim oPartDoc As Document Dim oSheet As Sheet Dim oTG As TransientGeometry Dim oPoint1 As Point2d Dim oPoint2 As Point2d Dim oPoint3 As Point2d Dim oPonit4 As Point2d 'RDS dims in mm Dim sheetheight As Integer = 297 'sheet size A3 Dim sheetwidth As Integer = 420 'sheet size A3 Dim tableheight As Integer = 51 'type A Dim tablewidth As Integer = 160 'type A Dim borderoffset As Integer = 10 'rounded up Dim viewdis As Integer =10 'selective Dim baseviewheight As Integer = Height Dim baseviewwidth As Integer = Length Dim fitspaceheight As Integer = sheetheight -tableheight - (2*borderoffset)-(3*viewdis) Dim fitspacewidth As Integer = sheetwidth- (2*borderoffset)-(2*viesdis)-50 Dim Hscale As Double = Height/fitspaceheight Dim Wscale As Double = Length/fitspacewidth Dim scale As Double If Wscale> Hscale Then scale=Wscale Else If Hscale>Wscale Then scale=Hscale Else If Hscale=Wscale Then scale=Hscale End If Dim Xfactor As Double Dim Yfactor As Double Dim Yfactortop As Double Dim Xfactorright As Double Dim Yfactorsection As Double Xfactor =((Length/(scale*2))+borderoffset+viewdis)/10 Yfactor=(sheetheight-(Height/(scale*2))-viewdis-borderofset-borderoffset)/10 Yfactortop= Yfactor-(Height/(scale*20))-(viewdis/10) Xfactorright=Xfactor+(Length/(scale*20))+(viewdis/10) Yfactorsection=(sheetheight-viewdis-borderofset)/10 'RDS ends dim% 'RDS places base view and other based on the file type assembly/part: If AssemblyDrawing = True Then oPartDoc = ThisDoc.Document oDrawDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, "C:\Users\Public\Documents\Autodesk\Inventor 2016\Templates\Standard_RDS.idw", True) Else If AssemblyDrawing = False oPartDocPath = ThisDoc.Path & "\" & PartNumber & ".ipt" oPartDoc = ThisApplication.Documents.Open(oPartDocPath, False) oDrawDoc = ThisApplication.ActiveDocument End If oSheet = oDrawDoc.Sheets.Item(1) oTG = ThisApplication.TransientGeometry oPoint1 = oTG.CreatePoint2d(Xfactor,Yfactor) oPoint2 = oTG.CreatePoint2d(Xfactor, Yfactortop) oPoint3 = oTG.CreatePoint2d(Xfactorright, Yfactor) oPoint4 = oTG.CreatePoint2d(Xfactor, Yfactorsection) 'RDS Creates the Base View: kHiddenLineRemovedDrawingViewStyle kHiddenLineDrawingViewStyle oBaseView = oSheet.DrawingViews.AddBaseView(oPartDoc, oPoint1, DrawingViewScale, kFrontViewOrientation, kHiddenLineRemovedDrawingViewStyle, "Default") 'RDS places other views: If ViewsToPlace = "Top" Then oView2 = oSheet.DrawingViews.AddProjectedView(oBaseView, oPoint2, kHiddenLineRemovedDrawingViewStyle, DrawingViewScale) Else If ViewsToPlace = "Right" oView2 = oSheet.DrawingViews.AddProjectedView(oBaseView, oPoint3, kHiddenLineDrawingViewStyle, DrawingViewScale) Else If ViewsToPlace = "Project" oView2 = oSheet.DrawingViews.AddProjectedView(oBaseView, oPoint4, kHiddenLineDrawingViewStyle, DrawingViewScale) Else If ViewsToPlace = "Top_Right" oView2 = oSheet.DrawingViews.AddProjectedView(oBaseView, oPoint2, kHiddenLineRemovedDrawingViewStyle, DrawingViewScale) oView3 = oSheet.DrawingViews.AddProjectedView(oBaseView, oPoint3, kHiddenLineRemovedDrawingViewStyle, DrawingViewScale) Else If ViewsToPlace = "Top_Project" oView2 = oSheet.DrawingViews.AddProjectedView(oBaseView, oPoint2, kHiddenLineDrawingViewStyle, DrawingViewScale) oView3 = oSheet.DrawingViews.AddProjectedView(oBaseView, oPoint4, kHiddenLineDrawingViewStyle, DrawingViewScale) Else If ViewsToPlace = "Right_Project" oView2 = oSheet.DrawingViews.AddProjectedView(oBaseView, oPoint3, kHiddenLineDrawingViewStyle, DrawingViewScale) oView3 = oSheet.DrawingViews.AddProjectedView(oBaseView, oPoint4, kHiddenLineDrawingViewStyle, DrawingViewScale) Else If ViewsToPlace = "Top_Right_Project" oView2 = oSheet.DrawingViews.AddProjectedView(oBaseView, oPoint2, kHiddenLineDrawingViewStyle, DrawingViewScale) oView3 = oSheet.DrawingViews.AddProjectedView(oBaseView, oPoint3, kHiddenLineDrawingViewStyle, DrawingViewScale) oView4 = oSheet.DrawingViews.AddProjectedView(oBaseView, oPoint4, kHiddenLineDrawingViewStyle, DrawingViewScale) Else If ViewsToPlace="Top_Section" oView2 = oSheet.DrawingViews.AddProjectedView(oBaseView, oPoint2, kHiddenLineRemovedDrawingViewStyle, DrawingViewScale) 'RDS dims a line to cut the section Dim oDrawingSketch As DrawingSketch oDrawingSketch = oSheet.Sketches.Add oDrawingSketch.Edit Dim oSketchLine As SketchLine oSketchLine = oDrawingSketch.SketchLines.AddByTwoPoints(oPoint2,oPoint4) oDrawingSketch.ExitEdit 'RDS places section view 'Dim oView3 As SectionDrawingView 'at Inventor.DrawingViews.AddSectionView(DrawingView ParentView, DrawingSketch SectionLineSketch, Point2d Position, DrawingViewStyleEnum ViewStyle, Object Scale, Boolean ShowLabel, String Name, Boolean Reserved, Boolean FullDepth, Object SectionDepth) oView4 = oSheet.DrawingViews.AddSectionView(oBaseView,oDrawingSketch, oPoint3, kHiddenLineRemovedDrawingViewStyle,DrawingViewScale) 'oDrawingSketch.Visible = False 'RDS ends section job Else If ViewsToPlace = "None" Then 'Only Place Base View, therefore do nothing End If Return oDrawDoc End Function 'RDS dims new function Function Structureview (STS As Boolean) If STS=True Then For i=1 To row Component.IsActive("Facade-Row"&i) = False Component.IsActive("MetalFrame-Glass-Row"&i) = False Component.IsActive("MetalFrame-MDF-Row"&i) = False Component.IsActive("Sticker"&i) = False Component.IsActive("Top-Facade") = False Component.IsActive("Right Facade:2") = False Component.IsActive("Right Facade:1") = False Component.IsActive("Left Facade:2") = False Component.IsActive("Left Facade:1") = False Next Else If STS=False Then 'RDS asks user if he/she is done with structure ' askagain: ' structuredoneq=MessageBox.Show(" Are you Done with Structure? note that you would not do anything else while working on structure(RDS) ", "Sajiran-Beta Partitioning System",MessageBoxButtons.YesNo,MessageBoxIcon.Question) ' If structuredoneq=vbYes Then iLogicVb.RunRule("Beta Partitioning System") ' Else If structuredoneq=vbNo Then ' 'RDS return ' Goto askagain ' End If End If End Function 'RDS ends rule
and errors i get is like this in error message tab:
Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
and so in another one:
System.Runtime.InteropServices.COMException (0x80004005): Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL)) at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData) at Inventor.DrawingViews.AddSectionView(DrawingView ParentView, DrawingSketch SectionLineSketch, Point2d Position, DrawingViewStyleEnum ViewStyle, Object Scale, Boolean ShowLabel, String Name, Boolean Reserved, Boolean FullDepth, Object SectionDepth) at LmiRuleScript.CreateDrawing_PlaceViews(String PartNumber, Double DrawingViewScale, String ViewsToPlace, Boolean AssemblyDrawing, DrawingView& oBaseView, DrawingView& oView2, DrawingView& oView3, SectionDrawingView& oView4) at LmiRuleScript.Main() at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem) at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)
do you have any idea what is is wanna tell????
Solved! Go to Solution.