Article | 41016020 |
Type | HowTo |
Product | Engine |
Version | 4.0.0.1016 |
Date Added | 3/5/2003 |
Submitted by | Christer Eckard |
Keywords |
How to add XProperties using the C interface (VC ++).
Cvdxyz
p1,p2;
p1.CreateDispatch("VDXYZ");
p2.CreateDispatch("VDXYZ");
p1.SetValueEx(1,2,3);
p2.SetValueEx(4,5,6);
CvdLine line = m_Vdraw.GetActiveDocument().GetActiveLayOutEntities().AddLine(COleVariant(p1.GetValue()),COleVariant(p2.GetValue()));
CvdXProperties xprops = line.GetXProperties();
//add a string type xproperty to xproperties collection of line
object
xprops.AddXProperty("property1",1000,COleVariant("mystring"));
//add a point type xproperty to xproperties collection of line
object
xprops.AddXProperty("property2",1010,COleVariant(p1.GetValue()));
//read xproperties
CString name ,msg;
long
type;
COleVariant value;
for(int i = 0 ; i <
line.GetXProperties().GetCount();i++){
name =
line.GetXProperties().GetItem(i).GetName();
type =
line.GetXProperties().GetItem(i).GetType();
value =
line.GetXProperties().GetItem(i).GetValue();
if(type ==
1000){
msg.Format("\n%s,%i,%s",name,type,CString(value.bstrVal));
OutputDebugString(msg);
}else
if(type ==
1010){
p1.SetValue(value);<
BR> msg.Format("\n%s,%i, x=%f,y=%f,z=%f",name,type,p1.GetX(),p1.GetY(),p1.GetZ());
OutputDebugString(msg);
}
}