VBA changes entities property when it should change sketch property as a whole.

VBA changes entities property when it should change sketch property as a whole.

tom.prichard
Contributor Contributor
367 Views
5 Replies
Message 1 of 6

VBA changes entities property when it should change sketch property as a whole.

tom.prichard
Contributor
Contributor

Without using VBA there are two ways to modify a drawing sketch's lineweight property.

1) Individually, per entity, from inside the sketch.

EntityProperty.jpg

2) As a whole, per sketch, from outside the sketch.

SketchProperty.jpg

 

VBA should allow a macro to be written to use either method.

You might tell me I'm the one making a mistake here, but I think when VBA modifies a sketch as a whole from outside the sketch it is actually overriding the all entities within the sketch. Which isn't how it works without VBA (ref: screen cap above)

 

The code that should modify the sketch as a whole looks something like this,,,

 

Dim oDoc As DrawingDocument
Dim oSketch As DrawingSketch
Set oDoc = ThisApplication.ActiveDocument
Set oSketch = oDoc.ActiveSheet.Sketches(oDoc.ActiveSheet.Sketches.Count)
oSketch.LineWeight = 0.0508

 

,,,,after the code has run & ended,,, if you edit the sketch to inspect the entities within; it changed them individually.

0 Likes
368 Views
5 Replies
Replies (5)
Message 2 of 6

tom.prichard
Contributor
Contributor

It looks like I got a few views but no replies. ,,,so perhaps the initial post was not clear.

 

I think I have discovered a bug where VBA should work with a drawing sketch's property, not just the entities in the sketch itself. Using AIP through its GUI you can see how the software is intended to work, and does work.

Using VBA to get AIP to perform the same task, in the correct method, however does not work correctly. The plotted/printed graphics may look the same, but the properties are not set to what should have been done.

 

0 Likes
Message 3 of 6

bradeneuropeArthur
Mentor
Mentor

For me this works fine:

Dim a As Inventor.DrawingDocument = ThisDrawing.Document

Dim sk As Inventor.DrawingSketch = a.ActiveSheet.Sketches.Item(1)
sk.LineWeight= 1

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 6

bradeneuropeArthur
Mentor
Mentor

and this for the entities based on lines only for my example:

Dim a As Inventor.DrawingDocument = ThisDrawing.Document

Dim sk As Inventor.DrawingSketch = a.ActiveSheet.Sketches.Item(1)
sk.Edit

Dim l As Inventor.SketchLine
l = sk.SketchLines.Item(1)
l.LineWeight = 6
sk.ExitEdit

  

bradeneuropeArthur_0-1614887970280.png

 

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 5 of 6

tom.prichard
Contributor
Contributor

What you have done is illustrate an issue with what is understood to be 'fine'.

The screen capture below illustrates how AIP does work through the GUI,,,

non-VBA_Output.jpg

This, below, is what your code outputs,,, incorrectly.

VBA_Output.jpg

Message 6 of 6

tom.prichard
Contributor
Contributor

It looks like Autodesk is ignoring this.

I do not consider this post solved.

 

So far we have illustrated a misunderstanding about how it is supposed to work.

Has anyone else verified the behavior of the software comparing it to the non-VBA(GUI mehod), and then with the VBA method?

0 Likes