TheSwamp

CAD Forums => Vertically Challenged => Land Lubber / Geographically Positioned => Topic started by: BlackBox on March 19, 2012, 05:21:55 PM

Title: Civil 3D Styles | Created By
Post by: BlackBox on March 19, 2012, 05:21:55 PM
Does anyone know if the 'Created By' value is stored somewhere, or if it is programmatically brought in at the time a new style is being created?

I am trying to set that for our company name, and am trying to see if this can be done in SysVar/Registry, etc. of if needs to be done programmatically after being created (.NET?), thanks.
Title: Re: Civil 3D Styles | Created By
Post by: Jeff_M on March 19, 2012, 06:15:26 PM
The default "Created By" is merely the user login name. It can be changed during style creation, and the value is accessible through the .NET API so it can be changed programatically as well.
Title: Re: Civil 3D Styles | Created By
Post by: BlackBox on March 19, 2012, 06:17:42 PM
... I had a feeling this would be relegated to a .NET solution.

Thanks for the clarification, Jeff
Title: Re: Civil 3D Styles | Created By
Post by: mjfarrell on March 19, 2012, 10:20:57 PM
I am wondering why one would expend the energy to do this?

Are people filching your styles?
Title: Re: Civil 3D Styles | Created By
Post by: BlackBox on March 20, 2012, 01:17:39 AM
Corporate directive... All styles are to have company name as 'Created by'. I'm actually just trying to save myself from having to do this manually, for each, and every, single, stinking, style. LoL
Title: Re: Civil 3D Styles | Created By
Post by: mjfarrell on March 20, 2012, 02:38:46 AM
Corporate directive... All styles are to have company name as 'Created by'. I'm actually just trying to save myself from having to do this manually, for each, and every, single, stinking, style. LoL
Someone (not you) needs to worry about more important things.....
Like serving the client needs and getting the jobs submitted on time.

The person requesting this obviously has nothing to do, if they are micromanaging to this extent.
Title: Re: Civil 3D Styles | Created By
Post by: huiz on March 20, 2012, 03:22:53 AM
It is reasonable to have a business template with styles named according business names convention. Also creation names can be set to a business name instead of pointing to one (or more) persons. It can look quite messy to have several names, even those who already left the company.

In case of drawings or projects it can be handy to see who created or edited styles, so in these drawings it is good to leave the names of the creators/editors.
Title: Re: Civil 3D Styles | Created By
Post by: mjfarrell on March 20, 2012, 04:14:19 AM
I'm not saying there should not be a naming convention applied to styles.

I am saying there is no value added to the client or the company, in expending any energy in setting the created by name. 
Title: Re: Civil 3D Styles | Created By
Post by: alanjt on March 20, 2012, 08:49:43 AM
I'm with you on this one, Michael.
Title: Re: Civil 3D Styles | Created By
Post by: Jeff_M on March 20, 2012, 02:06:03 PM
While I agree that this is micro-managing to the extreme, I can see a benefit for at least having the styles in a company template all set to the same 'created by' name. So attached is a ZIP file with a .NET dll that can be netloaded and run the command CREATEDBYUPDATE. You will be prompted for a new name then all styles in the drawing will be updated with the new value for "Created By:".

Anyone wanting the source code, just let me know. It is essentially the sample code for C3D provided in the Samples folder with some alterations. Works in C3D2010-2012.

Title: Re: Civil 3D Styles | Created By
Post by: huiz on March 20, 2012, 03:18:06 PM
Although I understand why people think this is not worth putting time in it, I believe that doing things nice, clean and neat with just the little things, it will help you be nice, clean and neat with the big things.

If you don't see any value in a nice business template, do you like naming conventions?

Or are you not interested in putting things in different layers?

Are you one of those people who don't care much about updating geometry, if one can update the dimension as well?

Or what about file naming, like "design today.dwg", "version 2 (1).dwg", "version 2 better.dwg", etc.

And there are people who don't comment code and name every control just Textbox1, Textbox2, Button1, etc (probably not on this forum)  :? :)


On the other hand, not everybody should be a hair-splitter  8) Just be effective with a little sense of tidiness... But I do like having a nice business template.
Title: Re: Civil 3D Styles | Created By
Post by: alanjt on March 20, 2012, 03:23:40 PM
I am a stickler for naming convention with styles, but the created by portion never phased me.
Title: Re: Civil 3D Styles | Created By
Post by: BlackBox on March 20, 2012, 06:08:59 PM
Too many posts to quote 'em - put simply, this stems from two main factors...

1) I'll use the analogy that my employer provides +/-80% of what we need by way of best practices, templates, etc. that is to be used as a starting point, given that we're +11K employee international firm. The rest is a free for all, and is up to us regional CAD Admins to work out in accordance with our client's, and regional standards in mind, based on the intent provided. Ergo, every region (may?) have a slightly different style (pun intended).

2) Corporate (despite being comprised of Canadians) is unable to locate the letter "I" in the word "Team," thus we (regional CAD Admins) shall do as they wish-aye... keeping track of who has created what will be done via the Modified property.

While I agree that this is micro-managing to the extreme, I can see a benefit for at least having the styles in a company template all set to the same 'created by' name. So attached is a ZIP file with a .NET dll that can be netloaded and run the command CREATEDBYUPDATE. You will be prompted for a new name then all styles in the drawing will be updated with the new value for "Created By:".

Anyone wanting the source code, just let me know. It is essentially the sample code for C3D provided in the Samples folder with some alterations. Works in C3D2010-2012.

Jeff - Just downloaded this, will give it a look-see after hours. I really appreciate your help!

Cheers! :beer:
Title: Re: Civil 3D Styles | Created By
Post by: BlackBox on March 20, 2012, 06:23:55 PM
FWIW -

Tested the .DLL in 2011 (both network, and local netload) and all result in fatal error. I made sure to unblock the .ZIP first. 2012 worked like a charm.
Title: Re: Civil 3D Styles | Created By
Post by: alanjt on March 20, 2012, 06:29:41 PM
Worked for me in 2011.
Title: Re: Civil 3D Styles | Created By
Post by: BlackBox on March 20, 2012, 07:12:39 PM
Worked for me in 2011.

... Hrm. I didn't even include it in my list of .DLL's which are net loaded at startup either - I manually netloaded, browsed, etc. I'll try it on 2011 again next time I log in.
Title: Re: Civil 3D Styles | Created By
Post by: BlackBox on March 20, 2012, 09:23:51 PM
Well, my problem with not working in 2011 was the modified acad.exe.Config I've been testing. I followed Kean's template (http://through-the-interface.typepad.com/through_the_interface/2011/07/loading-blocked-and-network-hosted-assemblies-with-net-4.html) to allow me to load from remote sources; and this worked well, without any noticeable issues (until now).

Enabling load from remote sources is something I am hoping to retain, moving forward, but I'll have to seek some education on acad.exe.Config in another thread (off topic).

Jeff - could you point me toward the (ObjectARX?) SDK sample code you mentioned earlier? There are several style related items I'm wanting to develop, and am just now digging into this aspect of the API.
Title: Re: Civil 3D Styles | Created By
Post by: Jeff_M on March 21, 2012, 12:58:34 AM
Jeff - could you point me toward the (ObjectARX?) SDK sample code you mentioned earlier? There are several style related items I'm wanting to develop, and am just now digging into this aspect of the API.
C:\Program Files\Autodesk\AutoCAD Civil 3D 2011\Sample\Civil 3D API\DotNet\CSharp\CompareStyles There are a few others in the same CSharp folder.
Title: Re: Civil 3D Styles | Created By
Post by: BlackBox on March 21, 2012, 01:25:50 AM
Thanks for the guidance, Jeff; I'll check that out tomorrow during lunch. You've been most helpful.
Title: Re: Civil 3D Styles | Created By
Post by: Jeff_M on March 27, 2012, 10:48:10 AM
Posting updated zip file with minor change to trap error thrown when a style collection has not been initialized.
Title: Re: Civil 3D Styles | Created By
Post by: BlackBox on March 27, 2012, 10:51:55 AM
Posting updated zip file with minor change to trap error thrown when a style collection has not been initialized.

Fantastic job - and thanks for the source code, Jeff!
Title: Re: Civil 3D Styles | Created By
Post by: BlackBox on March 31, 2012, 05:20:41 PM
Just as an update, I've taken Jeff's code (thanks again!) and slightly revised the CommandMethod to suite our use, and I am posting it here in the event that others may be interested.

In short, I revised the Prompt*Options to allow me to incorporate a Keyword (our company name), which allows the user to simply Enter, rather than manually typing out the company name each-and-every-time a change is made.

Also, a special thanks to Hallex (aka Oleg), for his suggestion of using *.Keywords.AllowArbitraryInput = true; as a work around to allowing 'string' input, and Keyword options in this post (http://forums.autodesk.com/t5/NET/GetString-with-Keywords-FATAL-ERROR/td-p/3373735).

Here's the code, note the 'companyName' variable at the top of the Class... Simply change this value to your company name and recompile:

Code - C#: [Select]
  1.         [CommandMethod("StylesCreatedBy")]
  2.         public static void StylesCreatedBy()
  3.         {
  4.             //
  5.             // Company name as string, to be used as default prompt option
  6.             //
  7.             String companyName = "SomeCompany"; //<-- Your company name goes here
  8.             //
  9.             Document acDoc = Application.DocumentManager.MdiActiveDocument;
  10.             CivilDocument civDoc = CivilApplication.ActiveDocument;
  11.  
  12.             PromptKeywordOptions myOpts = new PromptKeywordOptions("");
  13.             myOpts.Message = "\nEnter new value for 'Created By' in all styles or: ";
  14.  
  15.             // Define the valid keywords, specify default as 'companyName',
  16.             // and allow arbitrary input (spaces not accepted)
  17.             myOpts.Keywords.Add(companyName);
  18.             myOpts.Keywords.Default = companyName;
  19.             myOpts.AllowArbitraryInput = true;
  20.            
  21.             PromptResult myRes = acDoc.Editor.GetKeywords(myOpts);
  22.  
  23.             if (myRes.Status != PromptStatus.OK)
  24.                 return;
  25.             using (tr = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction())
  26.             {
  27.                 creator = myRes.StringResult;
  28.                 ListRoot(civDoc.Styles);
  29.                 tr.Commit();
  30.             }
  31.         }
  32.  

Cheers! :beer:

** Edit - Separately, I'd just like to point out how disappointed I am that .NET does not have an equivalent for:

Code: [Select]
_$ (setq var (getstring T "\nEnter a string or [Small/Medium/Large] <Large>: "))
"Something Else"
_$

... The idea of disallowing Keyword entry with GetString() Method is idiotic.

/vent
Title: Re: Civil 3D Styles | Created By
Post by: sinc on April 12, 2012, 11:09:54 PM
For the record, I tend to agree with MJFarrell and alanjt... I see no value in the "created by" field.

I suspect it was created by some misguided employee at Autodesk who wanted to flag the Autodesk-created styles as coming from them.  Or more-likely, some big beta-tester in one of the early versions of C3D, who told Autodesk that they wanted to tie their Styles to their company.

I personally view all of this as a moot point, and more like what happened with Blocks.  At one point, a lot of companies wanted to tie their Blocks to themselves.  Now everyone shares Blocks freely, and life is MUCH better for everyone involved.  It's possible to get "too possessive", and I think that's what's going on right now with C3D Styles.  Hopefully we get some sanity again soon.