Creating section views on drawing by ilogic rule

Creating section views on drawing by ilogic rule

malmal02122023
Advocate Advocate
449 Views
5 Replies
Message 1 of 6

Creating section views on drawing by ilogic rule

malmal02122023
Advocate
Advocate

Hello,

 

I would like to create sections view A-A to H-H for frame by Ilogic rule as shown below. Could you help me please?

There are sections with offset 10 mm from elements (L-rofiles 20x20x3) and section depth 40 mm. 

The section views with broken align and rotated to horizontal line.

 

malmal02122023_0-1704747806036.png

malmal02122023_1-1704747816945.png

 

malmal02122023_2-1704747842616.png

Thanks for the advice and Best regards

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

BM_Ashraf
Advocate
Advocate
Accepted solution

Hi,

You can adjust this code to fit your needs

Sub Main() 
 	'check
If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then Exit Sub 
	'Current Drawing Document
Dim oDrawDoc As DrawingDocument = ThisDoc.Document 
'Active sheet
Dim oSheet As Sheet = oDrawDoc.ActiveSheet
'Drawing View
Dim oFirst_view As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Please select the main view")
If oFirst_view Is Nothing Then Exit Sub
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry	
	'Adding a drawing sketch to the view
Dim oDrawingSketch As DrawingSketch = oFirst_view.Sketches.Add  
    oDrawingSketch.Edit
	'View height
    Dim oFWHeight As Double  = oFirst_view.Height+2
    'Points for secion line 
	Dim oPoints(1) As Point2d
    oPoints(0) = oTG.CreatePoint2d(0, oFWHeight)
    oPoints(1) = oTG.CreatePoint2d(0, -oFWHeight)
    'Sketch line(vertical)
    Dim oSketchLine As SketchLine = oDrawingSketch.SketchLines.AddByTwoPoints(oPoints(0), oPoints(1))
    Call oDrawingSketch.GeometricConstraints.AddVertical(oSketchLine)
    oDrawingSketch.ExitEdit
Dim oInsertionPoint As Point2d	= oTG.CreatePoint2d((oFirst_view.Position.X+oFirst_view.Width+1),(oFirst_view.Position.Y))
Dim oSectionView As SectionDrawingView
oSectionView = oSheet.DrawingViews.AddSectionView(oFirst_view, oDrawingSketch, oInsertionPoint, DrawingViewStyleEnum.kHiddenLineRemovedDrawingViewStyle)
oSectionView.ReverseDirection
End Sub 

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.

Blue Mech

Add-ins for Inventor!

Message 3 of 6

malmal02122023
Advocate
Advocate

Thank you very much. It works. I still have a question. How to give a name for view sections from work plane names in model (By creating view section along work plane 1, 2 itp. and naming them as work plane name?

Message 4 of 6

BM_Ashraf
Advocate
Advocate
Accepted solution

This one should do the job.

Sub Main() 
 	'check
If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then Exit Sub 
	'Current Drawing Document
Dim oDrawDoc As DrawingDocument = ThisDoc.Document 
'Active sheet
Dim oSheet As Sheet = oDrawDoc.ActiveSheet
'Drawing View
Dim oFirst_view As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Please select the main view, ESC to Cancel")
If oFirst_view Is Nothing Then Exit Sub
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry	
	'Adding a drawing sketch to the view
Dim oDrawingSketch As DrawingSketch = oFirst_view.Sketches.Add  
    oDrawingSketch.Edit
	'View height
    Dim oFWHeight As Double  = oFirst_view.Height+2
    'Points for secion line 
	Dim oPoints(1) As Point2d
    oPoints(0) = oTG.CreatePoint2d(0, oFWHeight)
    oPoints(1) = oTG.CreatePoint2d(0, -oFWHeight)
    'Sketch line(vertical)
    Dim oSketchLine As SketchLine = oDrawingSketch.SketchLines.AddByTwoPoints(oPoints(0), oPoints(1))
    Call oDrawingSketch.GeometricConstraints.AddVertical(oSketchLine)
    oDrawingSketch.ExitEdit
Dim oInsertionPoint As Point2d	= oTG.CreatePoint2d((oFirst_view.Position.X+oFirst_view.Width+1),(oFirst_view.Position.Y))
Dim oSectionView As SectionDrawingView
oSectionView = oSheet.DrawingViews.AddSectionView(oFirst_view, oDrawingSketch, oInsertionPoint, DrawingViewStyleEnum.kHiddenLineRemovedDrawingViewStyle)
oSectionView.ReverseDirection

'Getting the section name from Work Plane
'Referenced Document 
Dim oRDoc As Document = oFirst_view.ReferencedDocumentDescriptor.ReferencedDocument
ThisApplication.Documents.Open(oRDoc.FullDocumentName, True)
'Getting the WorkPlane Name 
Dim oWP As WorkPlane = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kWorkPlaneFilter, "Please select the Work Plane, ESC to Cancel")
If Not oWP Is Nothing Then oSectionView.Name = oWP.Name
oDrawDoc.Activate
End Sub  

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.

Blue Mech

Add-ins for Inventor!

Message 5 of 6

malmal02122023
Advocate
Advocate
Thank you again.
0 Likes
Message 6 of 6

malmal02122023
Advocate
Advocate

There is one more question.
In this code, a section is created through a sketch placed in the center of the main view. Is it possible to place a sketch on the selected working plane by previously selecting working plane?
Thanks again.

0 Likes