Adding sketch to drawing view

Adding sketch to drawing view

NachoShaw
Advisor Advisor
947 Views
4 Replies
Message 1 of 5

Adding sketch to drawing view

NachoShaw
Advisor
Advisor

Hey

 

i need to add a sketch to a drawing view. The sketch is a rectangle that is 1cm larger all round to the drawing view. I was looking at oView.Position and then deducting the width but it wasnt working for me.

 

guide.jpg

 

any help very much appreciated

 

Thanks

 

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes
Accepted solutions (1)
948 Views
4 Replies
Replies (4)
Message 2 of 5

bradeneuropeArthur
Mentor
Mentor

Something like this:

Public Sub DWGVIEW()

Dim a As Application
Set a = ThisApplication

Dim b As DrawingDocument
Set b = a.ActiveDocument

Dim c As Sheet
Set c = b.ActiveSheet

Dim d As DrawingView
Set d = c.DrawingViews.Item(1)

MsgBox (d.Width)
 Dim oTransGeom As TransientGeometry
    Set oTransGeom = ThisApplication.TransientGeometry
    
Dim x As Point2d
Dim y As Point2d
Dim z As Point2d
Set x = oTransGeom.CreatePoint2d(-(d.Width * 20) / 2, -(d.Height * 20) / 2)
Set y = oTransGeom.CreatePoint2d(d.Width * 20, -(d.Height * 20) / 2)
Set z = oTransGeom.CreatePoint2d(d.Width * 20, d.Height * 20)
'd.Sketches.Add.SketchLines.AddAsThreePointRectangle d.Width, d.Width, d.Height
'd.Sketches.Add '.SketchLines.AddByTwoPoints( x, y )(oTransGeom.CreatePoint2d(0, 0), oTransGeom.CreatePoint2d(10, 0))

Dim s As DrawingSketch
Set s = d.Sketches.Item(1)


 s.Edit
'Call s.SketchLines.AddByTwoPoints(x, y)
Call s.SketchLines.AddAsThreePointRectangle(x, y, z)
s.ExitEdit
End Sub

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 5

bradeneuropeArthur
Mentor
Mentor
Public Sub DWGVIEW()

Dim a As Application
Set a = ThisApplication

Dim b As DrawingDocument
Set b = a.ActiveDocument

Dim c As Sheet
Set c = b.ActiveSheet

Dim d As DrawingView
Set d = c.DrawingViews.Item(1)

 Dim oTransGeom As TransientGeometry
    Set oTransGeom = ThisApplication.TransientGeometry
       
Dim CenterView As Point2d

Dim x As Point2d
Dim y As Point2d
Dim z As Point2d
Set x = oTransGeom.CreatePoint2d(-(d.Width * 10) - 14 / 2, -(d.Height * 10) - 14 / 2)
Set y = oTransGeom.CreatePoint2d(d.Width * 10 + 14, -(d.Height * 10) + 14 / 2)
Set z = oTransGeom.CreatePoint2d(d.Width * 10 + 14, d.Height * 10 + 14)

Set CenterView = oTransGeom.CreatePoint2d(0, 0)

d.Sketches.Add '.SketchLines.AddAsThreePointRectangle d.Width, d.Width, d.Height

Dim s As DrawingSketch
Set s = d.Sketches.Item(1)
 s.Edit
Call s.SketchLines.AddAsTwoPointRectangle(x, z)
s.ExitEdit
End Sub
​
Public Sub DWGVIEW()

Dim a As Application
Set a = ThisApplication

Dim b As DrawingDocument
Set b = a.ActiveDocument

Dim c As Sheet
Set c = b.ActiveSheet

Dim d As DrawingView
Set d = c.DrawingViews.Item(1)

 Dim oTransGeom As TransientGeometry
    Set oTransGeom = ThisApplication.TransientGeometry
       
Dim CenterView As Point2d

Dim x As Point2d
Dim y As Point2d
Dim z As Point2d
Set x = oTransGeom.CreatePoint2d(-(d.Width * 10) - 14 / 2, -(d.Height * 10) - 14 / 2)
Set y = oTransGeom.CreatePoint2d(d.Width * 10 + 14, -(d.Height * 10) + 14 / 2)
Set z = oTransGeom.CreatePoint2d(d.Width * 10 + 14, d.Height * 10 + 14)

Set CenterView = oTransGeom.CreatePoint2d(0, 0)

d.Sketches.Add '.SketchLines.AddAsThreePointRectangle d.Width, d.Width, d.Height
'd.Sketches.Add '.SketchLines.AddByTwoPoints( x, y )(oTransGeom.CreatePoint2d(0, 0), oTransGeom.CreatePoint2d(10, 0))
Dim s As DrawingSketch
Set s = d.Sketches.Item(1)
 s.Edit
Call s.SketchLines.AddAsTwoPointRectangle(x, z)
s.ExitEdit
End Sub

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 4 of 5

bradeneuropeArthur
Mentor
Mentor
Accepted solution

Final one:

Public Sub DWGVIEW()

Dim a As Application
Set a = ThisApplication

Dim b As DrawingDocument
Set b = a.ActiveDocument

Dim c As Sheet
Set c = b.ActiveSheet

Dim d As DrawingView
Set d = c.DrawingViews.Item(1)

 Dim oTransGeom As TransientGeometry
    Set oTransGeom = ThisApplication.TransientGeometry
       
Dim CenterView As Point2d

Dim x As Point2d
Dim y As Point2d
Dim z As Point2d
Set x = oTransGeom.CreatePoint2d(-(d.Width / 2) * 1 / d.Scale - 13, -(d.Height / 2) * 1 / d.Scale - 13)
Set y = oTransGeom.CreatePoint2d(d.Width * 10 + 14, -(d.Height * 10) + 14 / 2)
Set z = oTransGeom.CreatePoint2d(d.Width * 10 + 13, d.Height * 10 + 13)

Set CenterView = oTransGeom.CreatePoint2d(0, 0)

d.Sketches.Add

Dim s As DrawingSketch
Set s = d.Sketches.Item(1)

s.Edit

Call s.SketchLines.AddAsTwoPointRectangle(x, z)
s.ExitEdit
End Sub

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

Message 5 of 5

NachoShaw
Advisor
Advisor

Hey

 

i was able to get what i needed working.

 

much appreciated mate

 

 

Thanks

 

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.