.NET

Reply
Contributor
annse
Posts: 15
Registered: ‎04-04-2012
Message 1 of 2 (120 Views)

PnId Database Overrule

120 Views, 1 Replies
05-31-2013 01:02 AM

Hi!

 

Does anyone know if there is an equivalent ObjectOverrule for the PnId Database?

 

If an entity is copied I dont want certain field values to be copied.

 

I've tried an ObjectOverrule but I can't get the RowId at that point.

 

I also noticed that the field values are set as XData. I edited the XData in my ObjectOverrule but the values still gets copied.

 

Is there a setting at project level to control which fields not to copy?

 

Thanks!

Annse

ADN Support Specialist
fenton.webb
Posts: 352
Registered: ‎07-24-2007
Message 2 of 2 (86 Views)

Re: PnId Database Overrule

06-05-2013 03:06 PM in reply to: annse

ObjectOverrule should apply to P&ID entities like all other entities. I am not sure off hand the exact order of events between our cloning code and the overrules. I do know we react to begin/end clone events and in the end clone do a lot of work to create rows in the project database, establish relationships, and copy row data.

 

I don’t think the Xdata is used in all situations. I know we attach Xdata with the property data so that we can insert DWGs (e.g. wblock followed by insert / explode).

 

It seems you simply want to prevent some project database row data from being copied?

 

I believe the best way to do that is to use the DataLinksManager events. 

 

 

        static private bool bIsActive = true;

        public static void dlm_DataLinkOperationOccurred(object sender, DataLinkEventArgs e)

        {

            if (e.Action == DataLinkAction.RowModified && bIsActive)

            {

                try

                {

                    DataLinksManager dlm = PlantProject.ActiveProjectPart.DataLinksManager;

 

                    if (dlm.HasProperty(e.RowId, "SAPCode"))

                    {

                        StringCollection props = new StringCollection();

                        props.Add("Size");

                        props.Add("Spec");

                       

                        StringCollection values = null;

                        values = dlm.GetProperties(e.RowId, props, true);

 

                        PpObjectIdArray ppoids = dlm.FindAcPpObjectIds(e.RowId);

 

                        StringCollection newprops = new StringCollection();

                        newprops.Add("SAPCode");

 

                        StringCollection newvals = new StringCollection();

                        newvals.Add(values[0] + values[1]);

 

                        bIsActive = false;

                        dlm.SetProperties(ppoids.First.Value, newprops, newvals);

                    }

                }

                catch

                {

                }

                finally

                {

                    bIsActive = true;

                }

            }

        }

 

        [CommandMethod("DEMOSTART", CommandFlags.Modal)]

        public static void DemoStart()

        {

            DataLinksManager dlm = PlantProject.ActiveProjectPart.DataLinksManager;

            dlm.DataLinkOperationOccurred +=new DataLinkEventHandler(dlm_DataLinkOperationOccurred);

        }

 

        [CommandMethod("DEMOEND", CommandFlags.Modal)]

        public static void DemoEnd()

        {

            DataLinksManager dlm = PlantProject.ActiveProjectPart.DataLinksManager;

            dlm.DataLinkOperationOccurred -= new DataLinkEventHandler(dlm_DataLinkOperationOccurred);

        }

 

 

That is sample code that updates a SAPCode property every time a row in the project is modified. It would need to be changed to react to rows being added / modified and blank out necessary properties.





Fenton Webb

Developer Technical Services

Autodesk Developer Network


You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community