I keep finding this same line used to accomplish this task but I always get a Object Variable not set error:

 

Dim swApp As Object

Dim ModelDocExtension As ModelDocExtension

Dim Part As Object

Dim boolstatus As Boolean

Dim longstatus As Long, longwarnings As Long

Dim instance As IModelDocExtension

Dim Units As Integer

 

 

Sub main()

 

Set swApp = Application.SldWorks

Set Part = swApp.ActiveDoc

boolstatus = instance.SetUserPreferenceInterger(swUserPreferenceIntegerValue_e.swUnitsLinearDecimalPlaces,swUserPreferenceOption_e.swDetailingNoOptionSpecified, 3)

 

End Sub


Categories: API∕Macros

Comments
Last comment By: Jesse Meiring   Tue, 13 Mar 2018 20:58:08 GMT
Re: Modifying Document Properties in a Part

Hello,

Jesse Meiring wrote:

 

I keep finding this same line used to accomplish this task but I always get a Object Variable not set error:

 

Dim swApp As Object

Dim ModelDocExtension As ModelDocExtension

Dim Part As Object

Dim boolstatus As Boolean

Dim longstatus As Long, longwarnings As Long

Dim instance As IModelDocExtension

Dim Units As Integer

 

 

Sub main()

 

Set swApp = Application.SldWorks

Set Part = swApp.ActiveDoc

boolstatus = instance.SetUserPreferenceInterger(swUserPreferenceIntegerValue_e.swUnitsLinearDecimalPlaces,swUserPreferenceOption_e.swDetailingNoOptionSpecified, 3)

 

End Sub

 

boolstatus = instance.SetUserPreferenceInterger <-Integer is misspelled

Could this be why?

 

Cheers,

 

Kevin

By: Kevin Chandler  Tue, 13 Mar 2018 19:24:46 GMT
Re: Modifying Document Properties in a Part

Oh geez that's a but embarrassing. Still receiving the same error unfortunately. I fear I may not be defining the IModelDocExtension correctly.

By: Jesse Meiring  Tue, 13 Mar 2018 19:38:39 GMT
Re: Modifying Document Properties in a Part

Hello,

 

What is this line doing?

Dim ModelDocExtension As ModelDocExtension

Also, can you define an object with the same name as its type?

 

Cheers,

 

Kevin

By: Kevin Chandler  Tue, 13 Mar 2018 20:03:38 GMT
Re: Modifying Document Properties in a Part

It's not doing anything anymore. I played with the code for a while before posting and that was left over. This should be cleaner:

 

Dim swApp As Object

Dim Part As Object

Dim boolstatus As Boolean

Dim instance As IModelDocExtension

 

Sub main()

Set swApp = Application.SldWorks

Set Part = swApp.ActiveDoc

 

boolstatus = instance.SetUserPreferenceInteger(swUserPreferenceIntegerValue_e.swUnitsLinearDecimalPlaces, swUserPreferenceOption_e.swDetailingNoOptionSpecified, 3)

 

End Sub

Not sure about the object question. Maybe? Definitely can't name a data type that way.

By: Jesse Meiring  Tue, 13 Mar 2018 20:11:14 GMT
Re: Modifying Document Properties in a Part

Dim swApp As Object

Dim Part As Object

Dim boolstatus As Boolean

Dim instance As ModelDocExtension

 

Sub main()

 

Set swApp = Application.SldWorks

 

Set Part = swApp.ActiveDoc

 

Set instance= Part.Extension 'was missing

 

boolstatus = instance.SetUserPreferenceInterger(swUserPreferenceIntegerValue_e.swUnitsLinearDecimalPlaces,swUserPreferenceOption_e.swDetailingNoOptionSpecified, 3)

 

End Sub

By: Artem Taturevych  Tue, 13 Mar 2018 20:54:18 GMT
Re: Modifying Document Properties in a Part

THANK YOU

By: Jesse Meiring  Tue, 13 Mar 2018 20:58:08 GMT
You are not authorized to view this page No results found! Suggestions: Check spelling, try a different search, or browse topics below.