Select to view content in your preferred language

Import CGA rule from different CityEngine project

4655
15
10-06-2016 01:40 AM
KristianMortensen1
Regular Contributor

Hello

I'm trying to create a CityEngine project where I want to add a facade to a building.

I have created the "Facade.cga" rulefile in a project called "Urb-Day" and now I want to use the same "Facade.cga" rule in another project called "stormwater".

I have tried to use the: import F_Facade: "Facade.cga" in the "Stormwater" project, and it works if the "Facade.cga" rulefile is located in the project "stormwater", but I would prefer that "Facade.cga" could be accessed when it is still placed in the "Urb-Day" project.  

I think it is just the path to the facade.cga rulefile that is wrong, any suggestions? 

Tags (1)
15 Replies
MatthiasBuehler2
Deactivated User

Hi Tim,

Sorry I had login issues as I'm changing accounts currently.

David has already given a few inputs, but to add some 'more behind the scenes insight'.

ce.lib:

- Is a low-level library with some CGA stuff that is supposed to not be changed.

- If you delete this project, it will be recreated on CE startup!

- [ This project can be made visible in the Navigator, but that's not needed for typical users. ]

ESRI.lib:

- As the name implies, it's content provided in a black box. DO NOT CHANGE IT or add your stuff to it.

- Referencing files from other projects just technically works the same as referencing FROM the Esri.lib. 'By design'.

- If you delete the ESRI.lib project, it will be recreated with the default values on CE startup!

general:

Goal: create your own libraries for all the stuff you reuse often.

* * *

On a separate note on this topic:

@ David :

It's great to have the complete streets you put your work in ( and literally mention or refer to it in every single post  ), but based on the technical discussion we've just had above, I believe you to should talk to our Esri colleagues to have your content pushed INTO the ESRI.lib. Why:

- It is confusing for users to see the distinction between what Esri and what other people provide and why they have to download e.g. all the plants twice, and so on.

- Streamlining the usability and proper integration in the above discussed 'LIBRARY' way of working would be helpful.

Again, thanks for all the hard work you provide for the community.

------------------------------------------------------------------------------------------------------------------
matthias buehler || dipl. arch. eth zurich
------------------------------------------------------------------------------------------------------------------

vrbn bühler
|| www.vrbn.io || winterthurerstrasse 51 || 8610 uster || switzerland
+41 78 930 04 07 || matthias.buehler@vrbn.io || @vrbnio @mattb3d

DavidWasserman
Frequent Contributor

Adjusted my answer accordingly. I knew altering any paths would be a bad idea. I did a quick test of adding something to Esri.lib showed it could be used that way, and it worked for a simple rule. However it definitely sounds like a bad idea.  Best practice sounds like creating your own library projects.

I can talk to you more off the post about that idea, but the short answer is we are trying to find another distribution solution. There are currently multiple distributions of the complete street rule and it is very confusing...not all of them are current with bug fixes etc. The rule was released on an Esri Attribution license and my contributions are under an additional Apache license (I have both in the project I have). I'll email you about it. 

PS: Hey you have your business card in every post, let me use the CS rule as a shameless example all of the place. XD Besides, I party on the other GIS threads too...


Thanks for the replies on this Matthias this has been helpful for me and the others on the thread. 

David

David Wasserman, AICP
0 Kudos
MatthiasBuehler3
Regular Contributor

If GeoNet had any proper signatures, I'd use those. Any other forum offers a personal signature about who you are, so that's a different thing.

I tend to like more general examples instead of lots of screenshots that need a long description and explanation, that are kinda OT. But I see other people may 'shamelessly' (your words ..) prefer the other thing, hehe.

0 Kudos
DavidWasserman
Frequent Contributor

I was kidding around. 😃 That makes sense. 

Fair enough. Pictures are fun though. 

David Wasserman, AICP
0 Kudos
CherylLau
Esri Regular Contributor

Yes, it's true.  File path info is either missing or really hard to find in the help pages.  We'll try to add this info to the help pages.  Thanks for pointing this out.

Thanks, Matt, for explaining it all quite well.

by Anonymous User
Not applicable

Now that you all have explained how paths work inside of CityEngine projects and workspaces, I'll add another useful detail. Rules and assets can be easily packaged as a "rule package" (file extension RPK). 

Right-click on a rule (.cga file), click "Share As...", then click Rule Package. The RPK file that is created bundles that rule, along with any imported rules, and any assets used by the rule. There will then be no dependencies on paths, absolute or relative. The RPK can be applied in any project, regardless of the existence of the original projects, such as ESRI.lib.

You can choose to "Include CGA source code", which allows users to see the rules and assets. This is what I do with all of my rules, so that others can learn from what I did right or wrong with the rule. The RPK is a zip file, and can be extracted to a folder, like any zip file (you don't need to change the file extension).

Also, RPKs can be applied as "symbology" in ArcGIS Pro. Similar to how a CGA rule is applied to a shape in CityEngine, in Pro, you can add the RPK to symbolize a feature layer, just like using a fill or stroke effect.

Note that importing some library rules, like the Plant_Loader, will include all of the assets used by that rule, which in the case of the Plant_Loader, will be 116MB of plant models added to the RPK. There are workarounds for this, which I won't go into here.

Hope this is useful for those who need to distribute a rule, without having to worry about what is in another user's workspace.

Chris