.NET

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

PnId Database Overrule

136 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 (102 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


Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.