How to add Xdata to new create object?

How to add Xdata to new create object?

Anonymous
Not applicable
2,079 Views
7 Replies
Message 1 of 8

How to add Xdata to new create object?

Anonymous
Not applicable

hi ,everyone . I create a new polyline and i want to add Xdata to polyline every point. how to do it?

0 Likes
2,080 Views
7 Replies
Replies (7)
Message 2 of 8

_gile
Consultant
Consultant

Hi,

 

This topic from the .NET Developer's Guide may help:

http://help.autodesk.com/view/ACD/2017/FRA/?guid=GUID-92D663FA-0452-44F4-BDAC-0EEF0AF3BD88



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 8

Anonymous
Not applicable

Hi,
I can use these to add xdata to each point in polyline2d and polyline3d because the point is vertex2d or vertex3d:
Polyline3d Polylin;
foreach (ObjectId id in Polyline)
{
id.Xdata=Values;
}
but how to do it in polyline; when i use : foreach (ObjectId id in Polyline) it doesn't work.

0 Likes
Message 4 of 8

_gile
Consultant
Consultant

Hi,

 

It looks like you're missing the AutoCAD .NET API basics.

You cannot add xdata to an ObjectId, you can only add xdata to DBObject (the base class for all graphic and non graphic database resident objects).

An ObjectId is an unique identifier which can be use to open the object itself (see this topic).

 

Assuming you create a new polyline (as said in the OP), for polyline 2d or 3d you have to create each vertex object.

You can add the xdata directly to the newly created vertex at this time.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 5 of 8

Anonymous
Not applicable
Poyline2d polyline;
foreach (ObjectId id in Polyline)
{
DBObject obj = id.GetObject(OpenMode.ForRead);
obj .Xdata=Values;
}
Like up, i can add xdata to point in polyline2d and polyline3d ,but my problem is can not add xdata to polyline. becase foreach (ObjectId id in Polyline) doesn't work when polyline is Polyline.
0 Likes
Message 6 of 8

_gile
Consultant
Consultant

Polyline (AKA Light Weigth Polyline, optimized polyline, LWPOLYLINE) is not a 'complex entity' (i.e. entities containing subentities).



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 7 of 8

Anonymous
Not applicable
you mean it is impossible to add xdata to point in polyline??
0 Likes
Message 8 of 8

Alexander.Rivilis
Mentor
Mentor

@Anonymous wrote:
you mean it is impossible to add xdata to point in polyline??

Yes. You can add xdata to whole Polyline, but can not add xdata to its vertexes because of vertexes are not objects/entities.

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

0 Likes