Message 1 of 5
DWG syntex

Not applicable
02-22-2018
12:54 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
hi there is this correct syntex to create a dwg from scratch ?
SyntaxEditor Code Snippet
Imports Inventor.ViewOrientationTypeEnum Imports Inventor.DrawingViewStyleEnum Dim oDrawingDoc As DrawingDocument Dim oPartDoc As PartDocument Dim oSheet As Sheet Dim oBaseView As DrawingView 'show dialog box asking the user are they sure they want to do this DWGcreate = MsgBox("would you like to create a drawing?" & vbLf & vbLf & "this will create a Base,Top,ISO view then section the base view",vbYesNo,"Ilogic") 'if the user says yes then do the following... If DWGCreate = vbYes Then opartdoc = ThisDoc.Document 'go and grabe the drawing file template and open oDrawingDoc = ThisApplication.Document.Add(DocumentTypeEnum.kDrawingDocumentObject, ThisApplication.FileManager.GetTemplateFile(DocumentTypeEnum.kDrawingDocumentObject)) 'Activate the drawing file oDrawingDoc.Activate() oSheet = oDrawingDoc.Sheets.Item(1) 'create a reference point to relate to the base view (x,y) oPoint1 = ThisApplication.TransientGeometry.CreatePoint2d(7,10) 'place the base view at point 1 oBaseView = oSheet.DrawingViews.AddBaseView(oPartDoc, oPoint1, 1/6, kFrontViewOrientation, kHiddenLineDrawingViewStyle) Dim otopview As DrawingView oPoint2 = ThisApplication.TransientGeometry.CreatePoint2d(7,23) otopview = oSheet.DrawingViews.AddProjectedView(oBaseView, oPoint2, DrawingViewStyleEnum.kFromBaseDrawingViewStyle) Dim oIsoView As DrawingView oPoint3 = ThisApplication.TransientGeometry.CreatePoint2d(35,23) oIsoview = oSheet.DrawingViews.AddProjectedView(oBaseView, oPoint3, DrawingViewStyleEnum.kShadedDrawingViewStyle) 'create a front section view by defining a section line in th base view Dim oSectionSketch As DrawingSketch OsectionSketch = obaseview.Sketches.Add oSectionSketch.Edit() 'Draw the section line Dim oSectionLine As SketchLine oSPoint1 = ThisApplication.TransientGeometry.CreatePoint2d(0,-30) oSPoint2 = ThisApplication.TransientGeometry.CreatePoint2d(0,30) oSectionLine = oSectionSketch.SketchLines.AddByTwoPoint(oSPoint1, oSPoint2) oSectionSketch.ExitEdit() Dim osectionview As SectionDrawingView oSPoint3 = ThisApplication.TransientGeometry.CreatePoint2d(35,23) osectionview = oSheet.DrawingViews.AddSectionView(obaseview, oSectionSketch, oSPoint3, DrawingViewStyleEnum.kShadedDrawingViewStyle, 1/6, True, "A") 'retrieve my dimensions dwgretrieve = MsgBox("would you like to bring through the dimensions" & vbLf & vbLf & "This will retrieve the dimesnions from views",vbYesNo, "Ilogic") If dwgretrieve = vbYes Then osheet.drawingdimensions.generaldimensions.retrieve(obaseview) End If End If
thanks.