Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Automatic drawing from ipt - issue

p.kaminskiG7KX4
Enthusiast

Automatic drawing from ipt - issue

p.kaminskiG7KX4
Enthusiast
Enthusiast

Hello everyone, 

 

I have some issue with ilogic code. I found code in this post:https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/ilogic-create-dimension-in-drawing/t... , This code is for automatic creation of drawing file from ipt with 2 views and one section view. I would like to implement this code to my flat parts configurator. Now I have some problem with creating drawing. The code works when the path to a specific file, on the basis of which it is to create projections, is given in line 3. I'd like drawing to automatically fetch views from the current file I just want to make. Can anyone help with this problem? The rule is named "Rysunek" in ipt file.

 

0 Likes
Reply
382 Views
3 Replies
Replies (3)

A.Acheson
Mentor
Mentor

Hi @p.kaminskiG7KX4 

Can you attach the code your looking to work with? It will be easier ro review and make recommendations if the code is visible. 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes

p.kaminskiG7KX4
Enthusiast
Enthusiast
Dim oModel As Document
Dim oSheet As Sheet
Dim oModelName As String = "C:\$ObszarRoboczyVault\Projekty Keller\Templates\OSŁONY - 2023.ipt" 

oModel= ThisApplication.Documents.Open(oModelName, False)

DWGcreate = MsgBox("Stworzyć rysunek wykonawczy?", vbYesNo, "")

If DWGcreate = vbYes Then
	
	'określenie szablonu rysunku
	Dim IDWTemplate As String = "C:\$ObszarRoboczyVault\Projekty Keller\Templates\OSŁONY - 2023.idw"
	
	'tworzenie pliku rysunku
	oDrawingDoc = ThisApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject, IDWTemplate, True)
	oDrawingDoc.Activate()
	oSheet = oDrawingDoc.Sheets.Item(1)
	
	'tworzenie rzutu bazowego
	Dim oPoint1 As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(7,10)

	oBaseView = oSheet.DrawingViews.AddBaseView(oModel, oPoint1, 1, ViewOrientationTypeEnum.kLeftViewOrientation, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle)
	
	'tworzenie rzutów
	Dim otopview As DrawingView
		Dim oPoint2 As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(7,23)
		otopview = oSheet.DrawingViews.AddProjectedView(oBaseView, oPoint2, DrawingViewStyleEnum.kFromBaseDrawingViewStyle)
		
	Dim osideview As DrawingView
		Dim oPoint3 As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(23,7)
		osideview = oSheet.DrawingViews.AddProjectedView(oBaseView, oPoint3, DrawingViewStyleEnum.kFromBaseDrawingViewStyle)
			
	'przekroje
	Dim oSectionSketch As DrawingSketch
	oSectionSketch = obaseview.Sketches.Add
	oSectionsketch.edit()
	
	Dim oSectionLine As SketchLine
	oSpoint1 = ThisApplication.TransientGeometry.CreatePoint2d(0, -7)
	oSpoint2 = ThisApplication.TransientGeometry.CreatePoint2d(0, 7)
	
	oSectionLine = oSectionSketch.SketchLines.AddByTwoPoints(oSPoint1, oSPoint2)
	oSectionSketch.ExitEdit()
	
	Dim osectionview As SectionDrawingView
	oSpoint3 = ThisApplication.TransientGeometry.CreatePoint2d(35,23)
		osectionview = oSheet.DrawingViews.AddSectionView(obaseview, oSectionSketch, oSPoint3, DrawingViewStyleEnum.kShadedDrawingViewStyle, 1, True, "A")
	
	
	
			
End If

0 Likes

A.Acheson
Mentor
Mentor

Hi @p.kaminskiG7KX4 

 

If you want to start from a part then you will need the part document object. This can be done with the ilogicAPI method which is ThisDoc.Document or the Inventor API method ThisApplication.ActiveDocument.

 

Dim oModel As PartDocument = ThisDoc.Document
'Dim oModel As PartDocument = ThisApplication.ActiveDocument Dim oSheet As Sheet Dim oModelName As String = "C:\$ObszarRoboczyVault\Projekty Keller\Templates\OSŁONY - 2023.ipt" oModel= ThisApplication.Documents.Open(oModelName, False)

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes