Change an XRef
Moderators: SDS, support, admin
Change an XRef
Hi,
I noticed that under CADImage.Converter you have XRefs. Is there a way to change the XRef?
See code attempt:
Objective:
We have a standard template that is used for most drawings but under some circumstances we need to change this template. The simple solution is to change the XRef on the fly. Can this be done?
I noticed that under CADImage.Converter you have XRefs. Is there a way to change the XRef?
See code attempt:
Code: Select all
this.cadEditorControl1.Image.Converter.XRefs[0].Dispose();
CADXRef NewXRef = new CADXRef();
NewXRef.AddCADImage(@"Z:\MFG\WF\MYXREF.DWG");
this.cadEditorControl1.Image.Converter.XRefs.Add(NewXRef);
this.cadEditorControl1.Image.Converter.Loads(NewXRef);
this.cadEditorControl1.Invalidate();
this.cadEditorControl1.Refresh();
We have a standard template that is used for most drawings but under some circumstances we need to change this template. The simple solution is to change the XRef on the fly. Can this be done?
Re: Change an XRef
Hello.
Changing an XRef object isn't correct. Correct method for your task is deleting XRef as well as insert and block representing it then adding a new XREf using vethod AddScaledDXF:
Alexander.
Changing an XRef object isn't correct. Correct method for your task is deleting XRef as well as insert and block representing it then adding a new XREf using vethod AddScaledDXF:
Code: Select all
CADEntityCollection ec = cadImage.Converter.XRefs;
string nm = null;
for (int i = 0; i < ec.Count; i++)
if (((CADXRef)ec[i]).Name == "name")
{
nm = ((CADXRef)ec[i]).Name;
ec.RemoveAt(i);
}
ec = cadImage.Converter.Entities;
for (int i = 0; i < ec.Count; i++)
if ((ec[i].EntType == EntityType.Insert) && (((CADInsert)ec[i]).Block.Name == nm))
ec.RemoveAt(i);
ec = cadImage.Converter.Blocks;
for (int i = 0; i < ec.Count; i++)
if (((CADBlock)ec[i]).Name == nm)
ec.RemoveAt(i);
CADImage img = CADImage.CreateImageByExtension(filename);
img.LoadFromFile(filename);
cadImage.AddScaledDXF(img, filename, new DPoint(0, 0, 0), new DPoint(1, 1, 1), 0);
cadImage.GetExtents();
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: Change an XRef
Thanks.
That did exactly what I wanted it to do. I have limited knowledge of Autocad so some things like this aren't obvious to me.
That did exactly what I wanted it to do. I have limited knowledge of Autocad so some things like this aren't obvious to me.
-
- Posts: 8
- Joined: 17 Jan 2017, 17:58
Re: Change an XRef
But is there a way to add the new file to the exact location, rotation etc of the original xref (before deletion)?
Dror
Dror
-
- Posts: 1
- Joined: 27 Oct 2023, 20:02
Re: Change an XRef
And what about saving a base file? How?
And how to delete references, if xrefs is not loaded?
And how to delete references, if xrefs is not loaded?
Last edited by sertaliano on 27 Oct 2023, 20:07, edited 1 time in total.
Re: Change an XRef
Hi!
XRefs are not deleted if there are some inserts with blocks into the XRef blocks.
Сall on an empty file and find out what is being created:
insert → block → xref.
Kind regards,
Suraya
XRefs are not deleted if there are some inserts with blocks into the XRef blocks.
Сall on an empty file and find out what is being created:
insert → block → xref.
Kind regards,
Suraya
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support