Defining model for views iLogic

Defining model for views iLogic

217694G9MEZ
Participant Participant
400 Views
1 Reply
Message 1 of 2

Defining model for views iLogic

217694G9MEZ
Participant
Participant

Hello. I have problem defining model for views in my code. It works for parts, but not for assemblies. I have code that will save the part up, then make drawing from it and places views. For some reason, it have problem just with assemblies. 

 

Code:

 

Dim oDrawingDoc As DrawingDocument
	oDrawingDoc = ThisApplication.ActiveDocument

    Dim oSheet As Sheet
	oSheet = oDrawingDoc.Sheets.Item(1)
	Dim doc = ThisDoc.Document
	
	If doc.DocumentType = kPartDocumentObject Then
    oWrite = System.IO.File.CreateText("C:\Users\ondra\OneDrive\Dokumenty\Inventor\Trans-technik\Nemazat3-iLogic.txt")
    oWrite.WriteLine(oFilePather & iProperties.Value("Project", "Part Number") & ".ipt")
    oWrite.Close()
    End If
	
	If doc.DocumentType = kAssemblyDocumentObject Then
	oWrite = System.IO.File.CreateText("C:\Users\ondra\OneDrive\Dokumenty\Inventor\Trans-technik\Nemazat4-iLogic.txt")
    oWrite.WriteLine(oFilePather & iProperties.Value("Project", "Part Number") & ".iam" )
    oWrite.Close()
    End If
	
	If doc.DocumentType = kPartDocumentObject Then
	oRead = System.IO.File.OpenText("C:\Users\ondra\OneDrive\Dokumenty\Inventor\Trans-technik\Nemazat3-iLogic.txt")
    EntireFile1 = oRead.ReadLine()
    oRead.Close()
    oPartName = EntireFile1 
    End If

    If doc.DocumentType = kAssemblyDocumentObject Then
	oRead = System.IO.File.OpenText("C:\Users\ondra\OneDrive\Dokumenty\Inventor\Trans-technik\Nemazat4-iLogic.txt")
    EntireFile2 = oRead.ReadLine()
    oRead.Close()
    oPartName = EntireFile2
    End if
	
    Dim oModel As PartDocument = ThisApplication.Documents.Open("C:\Users\ondra\OneDrive\Dokumenty\Inventor\TransTechnik\" & oPartName, False)

	
	'***Base View***
	Dim oPoint As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(oSheet.Height / 2-5, oSheet.Width / 2)
	Dim oView As DrawingView = oSheet.DrawingViews.AddBaseView(oModel, oPoint, 1#, ViewOrientationTypeEnum.kDefaultViewOrientation, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle)
	
	'***ProjectedViews***
	Dim oPoint2 As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(oView.Center.X + 10, oView.Center.Y)
    Dim oPoint3 As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(oView.Center.X, oView.Center.Y - 10)
	Dim oPoint4 As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(oView.Center.X +20, oView.Center.Y)
	
	Dim oView2 As DrawingView = oSheet.DrawingViews.AddProjectedView(oView, oPoint2, DrawingViewStyleEnum.kFromBaseDrawingViewStyle)
	Dim oView3 As DrawingView = oSheet.DrawingViews.AddProjectedView(oView, oPoint3, DrawingViewStyleEnum.kFromBaseDrawingViewStyle)
	Dim oView4 As DrawingView = oSheet.DrawingViews.AddBaseView(oModel, oPoint4, 1#, ViewOrientationTypeEnum.kIsoTopRightViewOrientation, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle)
	
	oView.Name = "POHLED1"
	oView2.Name = "POHLED2"
	oView3.Name = "POHLED3"
	oView4.Name = "POHLED4"

 

0 Likes
Accepted solutions (1)
401 Views
1 Reply
Reply (1)
Message 2 of 2

217694G9MEZ
Participant
Participant
Accepted solution

Okay. I have solved it. Didnt realize this line.

 Dim oModel As PartDocument

 

0 Likes