[VBA] Change position of existing Sketch Symbol and Parts List

[VBA] Change position of existing Sketch Symbol and Parts List

amarcoc
Advocate Advocate
1,597 Views
9 Replies
Message 1 of 10

[VBA] Change position of existing Sketch Symbol and Parts List

amarcoc
Advocate
Advocate

Hi.

 

How can I change position of existing Sketch Symbol and Parts List?

 

I created a macro to easely change Sheet Size, but I need to re-position Sketch Symbols and Parts List, but I couldn't do it.

 

Sketch Symbol Names are: "Tol Geral" and "Comentarios automaticos"

 

Thanks in advance!

0 Likes
Accepted solutions (3)
1,598 Views
9 Replies
Replies (9)
Message 2 of 10

marcin_otręba
Advisor
Advisor

sketched symbol:

 

 

oSketchedSymbol = odraw.ActiveSheet.SketchedSymbols.Item(1)
oSketchedSymbol.Position = g_inventorApplication.TransientGeometry.CreatePoint2d(1, 1)

 

 

partlist:

 

Set opartslist = osheet.PartsLists(1)
opartslist.Position = g_inventorApplication.TransientGeometry.CreatePoint2d(1, 1)

 

Hi, maybe you want to vote my:

Ideas

or check my apps:

DrawingTools   View&ColoringTools   MRUFolders   auto-save-replace

0 Likes
Message 3 of 10

amarcoc
Advocate
Advocate

Thanks!

 

I did try, but couldnt make it work. Is that for VBA?

 

Please check attached errors.

0 Likes
Message 4 of 10

marcin_otręba
Advisor
Advisor
Accepted solution

For vba you must  use set :

set oSketchedSymbol = odraw.ActiveSheet.SketchedSymbols.Item(1)

oSketchedSymbol.Position = g_inventorApplication.TransientGeometry.CreatePoint2d(1, 1)

 

you didint set osheet:

 

Dim osheet As Sheet
Set osheet = Thisapplication.activedocument.ActiveSheet
Set opartslist = osheet.PartsLists(1)
opartslist.Position = g_inventorApplication.TransientGeometry.CreatePoint2d(1, 1)

 

Hi, maybe you want to vote my:

Ideas

or check my apps:

DrawingTools   View&ColoringTools   MRUFolders   auto-save-replace

0 Likes
Message 5 of 10

amarcoc
Advocate
Advocate

I still cant make it work 😞

 

Here is the errorerro3.png

0 Likes
Message 6 of 10

marcin_otręba
Advisor
Advisor
Accepted solution

change g_inventorapplication to thisapplication.

Hi, maybe you want to vote my:

Ideas

or check my apps:

DrawingTools   View&ColoringTools   MRUFolders   auto-save-replace

0 Likes
Message 7 of 10

amarcoc
Advocate
Advocate

Thanks! That was it.

 

How can I know Part List height?

0 Likes
Message 8 of 10

marcin_otręba
Advisor
Advisor
Accepted solution
Dim oprtl As PartsList
Set oprtl = Thisapplication.activedocument.ActiveSheet.PartsLists.item(1)
Dim height, width As Decimal
Set  width = (oprtl.RangeBox.MaxPoint.X - oprtl.RangeBox.MinPoint.X)*10
Set height=(oprtl.RangeBox.MaxPoint.Y - oprtl.RangeBox.MinPoint.Y)*10

 

Sorry it was logic. i corrected it.

Hi, maybe you want to vote my:

Ideas

or check my apps:

DrawingTools   View&ColoringTools   MRUFolders   auto-save-replace

0 Likes
Message 9 of 10

amarcoc
Advocate
Advocate

Thanks. It worked.

 

Last question:

How can I check Model Documentype (running same VBA macro from a drawing?). I want partlist code to run only if model is an assembly.

 

Thanks!!!

0 Likes
Message 10 of 10

marcin_otręba
Advisor
Advisor
odraw.ReferencedDocuments.Item(1).documenttype

Hi, maybe you want to vote my:

Ideas

or check my apps:

DrawingTools   View&ColoringTools   MRUFolders   auto-save-replace

0 Likes