Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Setting default dimension styles different than object defaults in style library

10 REPLIES 10
Reply
Message 1 of 11
dick_upton
7749 Views, 10 Replies

Setting default dimension styles different than object defaults in style library

We have, as our standard library default dimension style, a 1/32 fractional style, called "1/32-FRACTION". Various Object Types, like Linear Dimension are set to this Object Style. When I create a drawing, then these Object Defaults are in effect.

 

This means that, doing nothing while executing a dimension command, I get fractional dimensions by default. This works good.

 

However, sometimes I want to create a drawing where the default dimension style is "X.XXX-DECIMAL" without changing the Object Defaults found in the style library. I've tried to make the changes from within the style library and then save this as a template. However, when I try to make a drawing based on this template, Inventor states that the styles in the template differ from the styles in the library" and then busily goes about undoing what I careful did.

 

So I'm hoping there is something in the API I can call on to do this with a macro. Is it possible to write a macro that after you start a drawing, flips all the various Object Styles from "1/32-FRACTION" to "X.XXX-DECIMAL"?

 

I've looked through these forums and see where someone is changing the default standard, but i can't seem to alter it to do what I want.

10 REPLIES 10
Message 2 of 11

Is there something stopping you from creating a new Standard that uses a different 'Object Defaults' that points to the appropriate styles and then making a new template file with the 'new' Standard as the Standard for said documant [document settings]?

----------------------------
Kristopher Reaves
Message 3 of 11

Each standard in a style library, like ANSI, comes with preset Object Defaults. For example, a LinearDimension defaults always to a certain dimension style unless changed manually or programmatically (my original request).

 

Are you suggesting I create an entire standard for each dimension style scheme and try to keep two standards synchronized and maintained, all identical but for which dimension style is the Object Default?!? I'm not prepared to do this. Thanks for the suggestion though.

 

 

Message 4 of 11

Hi dick_upton,

 

If I understand correctly, I think this can be done.

 

 

Let's say I have 3 Style sets that I use as follows:

 

 

Style Set 1 - used for sales drawings, color is blue, dims are 1 decimal place

 

Style Set 2 - used for shop drawings, color is green, dims are 2 decimal place

 

Style Set 3 - used for field drawings, color is brown, dims are fractional

 

 

Here's now I'd set this up.

 

 

First I'd create 3 Dimension styles:

 

Dim Style 1 - dims are 1 decimal place (all colors within the style are set to ByLayer)

 

Dim Style 2 - dims are 2 decimal place (all colors within the style are set to ByLayer)

 

Dim Style 3 - dims are fractional (all colors within the style are set to ByLayer)

 

 

Then I'd create 3 dim Layer styles to control the color:

 

Dim Layer 1 - color is blue

 

Dim Layer 2 - color is green

 

Dim Layer 3 - color is brown

 

 

Then I'd create 3 Object Default styles to control the the active dim style and layer style:

 

Style Set 1 - uses Dim Style 1 and Dim Layer 1

 

Style Set 2 - uses Dim Style 2 and Dim Layer 2

 

Style Set 3 - uses Dim Style 3 and Dim Layer 3

 

 

Then I'd create a template file that has the Object Default named Style Set 1 active (as per the Standard).

 

When I start a new file with this template it will always default to Object Default named Style Set 1, but I'll used an iLogic rule to let me choose and set the Object Default to one of the others based on the type of drawing I want (sales, shop or field). The ilogic will set the local Object Default based on a local parameter stored in the drawing called Style_Set

 

I'll also have an iLogic rule to check the Style_Set parameter each time the drawing is opened, and set the the local Object Default to match.

 

I'll try and follow up with this on Monday with an example, but does this sound like what you're after?

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com


 

 

Message 5 of 11
dick_upton
in reply to: dick_upton

This is precisely what I'm trying to accomplish. I've never considered doing it in iLogic however. I'm intrigued and wish to thank you very sincerely. It bugs me I am such a hack and can only do "cover tunes" of other artists' masterpieces. A cut here, a paste there. Ah well . . .

Message 6 of 11

Keep in mind the solution suggested would still require you to make different 'Object Defaults' which there seems to be an aversion to. The majority of the settings in 'Object Defaults' being directed to dimensions.

 

iLogic is just a dumbed down version of the VBA with easier hooks, your original question of finding the right code string to get to the object defaults, if it is uncovered, through the VB/iLogic framework.

 

----------

 

If there is no actual aversion to setting up the two (or more) Object Defaults styles then that would be a call to switch the Object Defaults style. Though considering the ease of switching just the Standard [which collection of styles just using a different ObjDefStyle with other preferences set and not hard to maintain].

 

Alternately, would you be adverse to just changing all the dimensions to a certain style after the fact, I wouldn't find that as a solution but perhaps it is an option for you.

 

I have in the past used the two standards with the only difference between the standards being the object defaults style settings, with the numerous dimension styles set appropriately. This being the intended purpose of the standards. Then setting the wanted standard as default on the intended template file.

 

----------

 

However the idea of taking that option out of the users hands and making it a coding change is intriguing and I will attempt to scour the object browser for said hook to manipulate, though it would be a number of dimension styles you would have to change.

----------------------------
Kristopher Reaves
Message 7 of 11

Hi dick_upton,

 

Okay, here's a bit of iLogic to get started. As KristopherReaves8819 mentioned this could be done with VB rather than iLogic if that's preferred.

 

 I'd suggest you create a test project and fool around with this using that project and style library first, to see if this works for you and to identify what tweaks might be needed, before trying it with your actual files.

 

So using the previous example, we would set our drawing template up to use a single Standard. The Standard can only use one Object Default. So let's say our default Object Default is : Style Set 1 > uses Dim Style 1 and Dim Layer 1

 

But the drawing template file has three Object defaults cached within it locally:

  • Style Set 1 - uses Dim Style 1 and Dim Layer 1
  • Style Set 2 - uses Dim Style 2 and Dim Layer 2
  • Style Set 3 - uses Dim Style 3 and Dim Layer 3

Likewise the Styles Library (XML file) contains all three Object defaults and all of the dimension and layer styles.

 

So we'll edit our drawing template file and add a Parameter with a Multi Value List named Style_Set. This parameter list contains the names: Style Set 1, Style Set 2, & Style Set 3. 

 

We'll then use the following rule to allow to select a Style Set (aka Object Default):

 

    'set active document as drawing document
Dim oDwgDoc As DrawingDocument
oDwgDoc = ThisApplication.ActiveDocument

Dim oDwgStlMgr As DrawingStylesManager
oDwgStlMgr = oDwgDoc.StylesManager

Dim oObjDfStl As ObjectDefaultsStylesEnumerator
oObjDfStl = oDwgStlMgr.ObjectDefaultsStyles

Style_Set = InputListBox("Select a style set to use:", MultiValue.List("Style_Set"), Style_Set, Title := "iLogic", ListName := "Select a Style Set")

 

We'll also use this second rule to check the drawing parameter (Style_Set) against the Object Default (Style Set 1, Style Set 2, or Style Set ) when ever the drawing is opened for edits, or saved, etc. by setting up rule event triggers.

 

    'set active document as drawing document
Dim oDwgDoc As DrawingDocument
oDwgDoc = ThisApplication.ActiveDocument

Dim oDwgStlMgr As DrawingStylesManager
oDwgStlMgr = oDwgDoc.StylesManager

Dim oObjDfStl As ObjectDefaultsStylesEnumerator
oObjDfStl = oDwgStlMgr.ObjectDefaultsStyles

'set Object Defaults as active object default style
If Style_Set = "Style Set 1" then
oDwgStlMgr.ActiveStandardStyle.ActiveObjectDefaults = oObjDfStl.Item("Style Set 1")
Else If Style_Set = "Style Set 2" then
oDwgStlMgr.ActiveStandardStyle.ActiveObjectDefaults = oObjDfStl.Item("Style Set 2")
Else If Style_Set = "Style Set 3" then
oDwgStlMgr.ActiveStandardStyle.ActiveObjectDefaults = oObjDfStl.Item("Style Set 3")
Else
End if

 

I've attached an example drawing here to use for testing if you would like. You'll want to create a test project and style library to work with and use the Save Style to Styles Library button to pull the styles from the drawing to the library.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

Message 8 of 11

Hi KristopherReaves8819, 

 

All good points. I think the idea in most companies is that there should only be one Standard. However using several Object Defaults within the standard is really the goal. As you mentioned we could just manipulate the styles individually, but I think using different Object Defaults helps this stay a bit more organized. Of course there might be reasons why this approach won't work in some cases.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

Message 9 of 11

I understand the want for a single style/standard. But when a person is asking to change the dimension style defaults that would be esentially a break from the standard. My querulousness is coming from trying to understand why you would be willing to jump through all the hoops to create the code, as easy as it is, that requires a button press or seperate process run everytime versus using the built in mechanism of just changing a standard. When the only thing that changes between the standards is the object defaults, which is the good majority of the standards. With a full change you can then limit and alternate decimal styles or fractional styles that are made available. The OP seemed to have an aversion to 'maintaining' two Object Default sets buried under easeily switchable standards, but seeing the code aspect of three Object Defaults/Layer sets there ensued happiness. I am a big believer in letting the software do as much for you as possible prior to injecting of personal code.. that being said;

 

If you through an hook for the placement of a part/base view that looked into the inserted part and looked at the units used there to drive the object default switch that would be something. If the part/assy being inserted was metric switch to metric obj defaults/standard vs imperial default (with a further check for fractional and decimal perhaps there). Then you could maintain the single 'standard.idw' template file without needing a separate template file. A quick headsup that the standard is needing to change with a yes/no and you would be in business.

----------------------------
Kristopher Reaves
Message 10 of 11

Hi Curtis,

 

Just got back from an ill-timed vacation, meaning I am now further behind on a project that I was behind on when I left, so it may be a week or more before I get a chance to review this new information.

 

Gratefully yours,

 

****

Message 11 of 11


@dick_upton wrote:

 

Are you suggesting I create an entire standard for each dimension style scheme and try to keep two standards synchronized and maintained, all identical but for which dimension style is the Object Default?!? I'm not prepared to do this. Thanks for the suggestion though.

 

 


 

@Mark.Lancaster , @SteveMDennis

 

This was the issue I was trying to remember concerning Company Standards.

 

Post 1, 2 and 3 discuss the issue, after that this thread delves into a customized solution.

 

The goal is a single template, with a single company standard, set up and managed by the CAD admin. Where the users can switch the "drawing style" with one click, rather than having to remember to switch dim styles, then switch balloon styles, leader styles, etc.

 

So for instance, if they want to create a "Sales Drawing" they would open the template and switch a "Drawing Style" (which is really just the Object Defaults collection) to "Sales". 

 

If they needed to create a "Detail Drawing" they would open the template and switch a "Drawing Style" to "Detail". 

 

.... a "General Arrangement Drawing", they would open the template and switch a "Drawing Style" to "Layout". 

 

As far as I know this can't currently be done this way without the users stepping into the Styles and Standards editor, which we don't want them to do. But this is the correct way for "enterprise" standards to be set up, used, and managed.

 

Basically as an admin, I would prefer users never dig into styles and standards, these should all be set up and managed by the admin. So using a "single template, single standard setup" ensures that the users start out correct, and makes it very easy for the these things to be managed.

 

Ultimately, what I would like is a "Drawing Style" drop down that sets the object defaults in "one fell swoop", as in this mock up:

 

Drawing Style.png

 

I do this currently with ilogic Smiley Wink , but the illogic is a bit different than the sample posted here. I feel like this should be built in though.

 

When you get a chance let me know what you think, and if you think I've not overlooked something that exists currently, etc. I'll write up an Idea.

 

Thanks!

 

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report