How to set Part Catalog via API for a drawing?

How to set Part Catalog via API for a drawing?

soonhui
Advisor Advisor
1,017 Views
11 Replies
Message 1 of 12

How to set Part Catalog via API for a drawing?

soonhui
Advisor
Advisor

For a drawing, I can call up the relevant dialog box and set the Part Catalog via the command line  _aeccsetnetworkcatalog ( for Network) and _aeccsetpressurenetworkcatalog ( for Pressure Network).

 

But can I do it via the .Net API? 

##########

Ngu Soon Hui

##########

I'm the Benevolent Dictator for Life for MiTS Software. Read more here


I also setup Civil WHIZ in order to share what I learnt about Civil 3D
0 Likes
Accepted solutions (1)
1,018 Views
11 Replies
Replies (11)
Message 2 of 12

norman.yuan
Mentor
Mentor

Well, Part Catalog is not set PER DRAWING, rather it is set as current user's preference, saved with AutoCAD profile in Window registry's HKEY_CURRENT_USER hive:

\HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R24.0\ACAD-[X]100:409\Profiles\[ProfileName]\Preferences\AeccUiNetwork130\

 

Underneath the registry key "AeccUiNetwork130", there should a a bunch of GUID subkeys, each points to a Part Catalog's *.apc file, which is in a Part Catalog folder.

 

The first GUID key (except for the "(Default)" key) is the current Part Catalog when AutoCAD runs with given profile. When you run the command "_aeccsetnetworkcatalog" which brings up a dialog box for user to select a current Part Catalog, the "AeccUiNetwork130" registry is updated by moving the selected part catalog GUID key to the top.

 

As you can see, the current Part Catalog is one of the C3D user preferences, not "PER DRAWING" based.

 

HTH

 

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 12

soonhui
Advisor
Advisor

@norman.yuan , thanks for the explanation.

 

But is there a .Net API that allows me to change the catalog without me messing around with the registry?

##########

Ngu Soon Hui

##########

I'm the Benevolent Dictator for Life for MiTS Software. Read more here


I also setup Civil WHIZ in order to share what I learnt about Civil 3D
0 Likes
Message 4 of 12

norman.yuan
Mentor
Mentor

No, there is no C3D API, I believe. Since the registry is in HKEY_CURRENT_USER hive, there should be no issue for current user to use code to update this registry to achieve the same result as do it via the dialog box in C3D.

 

Norman Yuan

Drive CAD With Code

EESignature

Message 5 of 12

soonhui
Advisor
Advisor

@norman.yuan , I thought you were right but upon further testing. Now I don't think so. 

 

Because I have two drawings, both opened at the same time in Civil 3D, and the Part Catalog Dialog box shows different Pipe/Structure Catalog.  See below:

 

metric.jpg

  

imperial.jpg

 

So I don't think the catalog setting is stored inside the registry and cannot be on per user machine basis, it must be on per drawing basis like Pressure Pipe Catalog

##########

Ngu Soon Hui

##########

I'm the Benevolent Dictator for Life for MiTS Software. Read more here


I also setup Civil WHIZ in order to share what I learnt about Civil 3D
0 Likes
Message 6 of 12

norman.yuan
Mentor
Mentor

Sorry I missed your latest message. thus the late reply here.

 

Actually, what matters in the "Pipe Network Catalog Settings" is the folder location for the catalogs (i.e. a folder that contains at least one, or multiple catalogs.

 

When the dialog is to open, C3D would first look at at available partslist in the drawing and determine the partfamilies in the partslist are from which catalog in that folder. Then set that catalog as the selected one in the dropdown list. While it is possible multiple partslists in a drawing could be built on different catalog technically with C3D, I'd consider it is extremely bad practice. 

 

For example, with the 2 drawing you attached here, when the "Catalog" dialog opens in my computer, the dropdown lists are all blank (no catalog is selected), because the catalog folder in my computer has a different folder location than the default C3D settings, and in my catalogs folder, there is no catalog name like "US Imperial..." or "Metric ...", all Catalogs in the folder of my computer are named differently. However, C3D only search the folder saved in the HKCU registry for partfamilies-matched catalog based on partslist in the drawing, when opening that dialog.

 

You can also verify it by renaming the "US Imperial...." catalog file to something else. Then if you open the dialog, you would see the default catalog changes to the newly named catalog, because the partslist's partfamilies match the ones in that catalog.

 

It would all become messy if the drawing has multiple partslist based different catalogs. Again, it is bad practice and should be avoid with all efforts.

 

 

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 7 of 12

DJB_CADfx
Enthusiast
Enthusiast

We have a need to enable this same functionality for Civil 3D Pipes Catalog and Pressure Pipes Catalog. We had a solution in place for years that renamed the local C:\ProgramData\Autodesk\C3D 202[X]\enu\Pipes Catalog folder temporarily and then created a Symbolic Link named Pipes Catalog in its place which pointed to the network location used on the specific project the drawing belonged to. However, creation of Symbolic Links on the fly has become a problem with the IT department as it requires Administrator rights to do it, and security is now dictating that standard BIM users not have local Admin privileges any longer.

So, I found this thread while searching for another method to accomplish the same task. My question is, how does Acad.exe get notified that the \HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R24.0\ACAD-[X]100:409\Profiles\[ProfileName]\Preferences\AeccUiNetwork130\ values have been modified in the registry and need to be re-read in? 

Message 8 of 12

soonhui
Advisor
Advisor

@DJB_CADfx , how does acad.exe get notified and to reread?

 

The answer is: whenever you open the drawing and operate on it?

##########

Ngu Soon Hui

##########

I'm the Benevolent Dictator for Life for MiTS Software. Read more here


I also setup Civil WHIZ in order to share what I learnt about Civil 3D
0 Likes
Message 9 of 12

varshaauti27
Advocate
Advocate

Hi,

Did you manage to find a workaround to set the Catalog programmatically? Also, do you know if the Pipe/Pressure Network catalog path is drawing-specific or machine-specific?

0 Likes
Message 10 of 12

soonhui
Advisor
Advisor
Accepted solution

@varshaauti27 , thanks for the question(s). I've actually written 3 posts addressing them all

 

  1. Gravity Network is machine specific
  2. Pressure Network is drawing specific
  3. You have to change registry in order to set Catalog programmatically.
##########

Ngu Soon Hui

##########

I'm the Benevolent Dictator for Life for MiTS Software. Read more here


I also setup Civil WHIZ in order to share what I learnt about Civil 3D
Message 11 of 12

varshaauti27
Advocate
Advocate

@soonhui 

Thank you for the detailed explanation. Do you have a sample code snippet to set the network catalog programmatically, either using C# or AutoLISP?

0 Likes
Message 12 of 12

soonhui
Advisor
Advisor

@varshaauti27 , no I don't have yet. But I think you can search online on how to read or write registry value. It should be simple. I may even consider adding them to the blog post section in the future. 

##########

Ngu Soon Hui

##########

I'm the Benevolent Dictator for Life for MiTS Software. Read more here


I also setup Civil WHIZ in order to share what I learnt about Civil 3D