Placing a drawing using iLogic

Placing a drawing using iLogic

Anonymous
Not applicable
880 Views
5 Replies
Message 1 of 6

Placing a drawing using iLogic

Anonymous
Not applicable

Hi,

 

I've tried searching in the forum and basically this is where I kinda get the code where I modified it to suit my needs but I keep on getting this error:

 

Error in rule: drawing view test, in document: L19-4949 PLATE, CENTER BRACKET.ipt

 

Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))

 

--so basically from part, I'd run this rule and it opens the drawing fine to the border that I want, then that error appears.  Any help, insight is greatly appreciated.

 

Thanks in advance!!

Joel

 

 

Format:HTML Format Version:1.0 StartHTML: 165 EndHTML: 17334 StartFragment: 314 EndFragment: 17302 StartSelection: 314 EndSelection: 314SyntaxEditor Code Snippet

    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
    
    Filename = ThisDoc.FileName(False)
    
    'If this is the Assembly View, then use this Document as reference and open Drawing Template
    'Otherwise use the given Part Number And invisibly open the part, Use the active drawing
    If AssemblyDrawing = True Then
        oPartDoc = ThisDoc.Document
        oDrawDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, "C:/Vault_Work/PROJECTS/iLogic Parts-inprogress/iLogic Part Generators/Rectangular Transition Chute Generator/DrawingTemplate.idw", True)
    Else If AssemblyDrawing = False 
        oPartDocPath = ThisDoc.Path & "\" & Filename & ".ipt"
        oPartDoc = ThisApplication.Documents.Open(oPartDocPath, False)
        'oDrawDoc = ThisApplication.ActiveDocument 
        oDrawDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, "K:\Mech\INVENTOR2016\Inventor Resources\Templates\RAUTE_2016.dwg", True)
    End If
    
'Set a reference to the sheet format
Dim oFormat As SheetFormat
Try
oFormat = oDrawDoc.SheetFormats.Item("A-SIZE SHEET")
Catch
MessageBox.Show("Error: the named sheet format might not exist.", "iLogic")
Return
End Try
'Create a new sheet based on the sheet format using the specified model'Dim oSheet As Sheet
oSheet = oDrawDoc.Sheets.AddUsingSheetFormat(oFormat)    

oSheetName = "Sheet:1"
oSheet = ThisApplication.ActiveDocument.Sheets.Item(oSheetName) 
oSheet.Delete

oTG = ThisApplication.TransientGeometry
    'Dim oTG As TransientGeometry'Set points in order to get wanted View (ie. if 'Y' is the same and 'X' is greater or less, you will get a Side View)
    oPoint1 = oTG.CreatePoint2d(5, 5)
    
DrawingViewScale = 1

'Create the Base View
    oBaseView = oSheet.DrawingViews.AddBaseView(oPartDoc, oPoint1, DrawingViewScale, ViewOrientationTypeEnum.kFrontViewOrientation, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle, "Master")

 

0 Likes
Accepted solutions (1)
881 Views
5 Replies
Replies (5)
Message 2 of 6

JaneFan
Autodesk
Autodesk
Accepted solution

Hi Joel,

 

Please try to define a new name oSheet1 instead of oSheet since oSheet is going to be deleted, while it need still be used to create a drawing view.

Try following modification in the code:

oSheetName = "Sheet:1"
oSheet1 = ThisApplication.ActiveDocument.Sheets.Item(oSheetName)
oSheet1.Delete




Jane Fan
Inventor/Fusion QA Engineer
0 Likes
Message 3 of 6

Anonymous
Not applicable

Thanks Jane,

 

I was able to fix it too yesterday by doing the code below but yours is a lot better

 

Format:HTML Format Version:1.0 StartHTML: 165 EndHTML: 2306 StartFragment: 314 EndFragment: 2274 StartSelection: 314 EndSelection: 314SyntaxEditor Code Snippet

oSheet = oDrawDoc.Sheets.AddUsingSheetFormat(oFormat)    

oSheetName = "Sheet:1"
oSheet = ThisApplication.ActiveDocument.Sheets.Item(oSheetName) 
oSheet.Delete

oSheet = oDrawDoc.Sheets.Item(1)
0 Likes
Message 4 of 6

Anonymous
Not applicable

Jane,

 

kinda a side question but would you happen to know what I need to do if I want my scale in the drawing view to be 3" = 1'-0"

 

Format:HTML Format Version:1.0 StartHTML: 165 EndHTML: 600 StartFragment: 314 EndFragment: 568 StartSelection: 314 EndSelection: 314SyntaxEditor Code Snippet

DrawingViewScale = ?

 

0 Likes
Message 5 of 6

JaneFan
Autodesk
Autodesk

Hi Joel,

 

I don't quite understand the question about the scale value 3" = 1'-0". DrawingViewScale only accepts double input. You can set it to any double value as needed.

Drawing view scale can be set either when calling DrawingViews.Addxxx() functions, or after drawing view being created, Modifying the property of drawing view: DrawingView.Scale.




Jane Fan
Inventor/Fusion QA Engineer
0 Likes
Message 6 of 6

Anonymous
Not applicable

Hi Jane,

 

This is what I mean..i set the drawingscaleview to .125 which is 1/8 scale but I want it to say 1 1/2" = 1'-0" just the drop down shown below.  What should I change in my code then? Thanks for your help!

 

 

0 Likes