One immediate optimization that comes to mind, is doing all your filtering inside of one loop:
// try get all different user data types
foreach obj in doc.Objects {
var myCbrep1 = obj.Attributes.UserData.Find(typeof(MyCustomBrepUserData1)) as MyCustomBrepUserData1;
var myCbrep2 = obj.Attributes.UserData.Find(typeof(MyCustomBrepUserData2)) as MyCustomBrepUserData2;
var myCcurve = obj.Attributes.UserData.Find(typeof(MyCustomCurveUserData)) as MyCustomCurveUserData;
// at max only one of your variables won't be null
if(!(myCbrep1 is null)){ // do stuff}
if(!(myCbrep2 is null)){ // do stuff}
if(!(myCcurve is null)){ // do stuff}
}
This is just pseudo-code, I’m not sure right now if the as - casting will throw if no userdata is found
I have a better solution which takes advantage of the fact, that all UserData derives from DataBase
ins the Octopus project, but it is not implemented as of yet and sadly I don’t really know when I will find the time to do that. I can keep you updated