Create a new custom vertex property for AcDbPolyline

Create a new custom vertex property for AcDbPolyline

xgritsios
Explorer Explorer
219 Views
5 Replies
Message 1 of 6

Create a new custom vertex property for AcDbPolyline

xgritsios
Explorer
Explorer

I am trying to create my own custom property that acts just like "Vertex X" and "Vertex Y" properties but without the graphical effect. I just want for every vertex to have a new dynamic property that depends and is connected to each one of the vertices.

 

I am relatively new to the ObjectARX concept and structure and how AutoCAD works. However, I have quite good understanding of the C++ language.

 

My thoughts are to, somehow, use the IOPMPropertyExtension and IOPMPropertyExpander. These interfaces can only be used from a wrapper -as I've concluded from the generated code from the wizards and an extensive research-.

 

So, my guess is that I should create a new custom object derived from AcDbPolyline and then wrap it to implement the needed methods. These methods seem to be:
STDMETHOD(GetElementValue)(/*[in]*/DISPID dispID, /*[in]*/DWORD dwCookie, /*[out]*/VARIANT *pVarOut);
STDMETHOD(SetElementValue)(/*[in]*/DISPID dispID, /*[in]*/DWORD dwCookie, /*[in]*/VARIANT VarIn);
STDMETHOD(GetElementStrings)(/*[in]*/DISPID dispID, /*[out]*/OPMLPOLESTR __RPC_FAR *pCaStringsOut, /*[out]*/OPMDWORD __RPC_FAR *pCaCookiesOut);
STDMETHOD(GetElementGrouping)(/*[in]*/DISPID dispID, /*[out]*/short *groupingNumber);
STDMETHOD(GetGroupCount)(/*[in]*/DISPID dispID, /*[out]*/long *nGroupCnt);

 

I have not understood how I should implement those.

I know I might have a big misconception about this topic that I have not discovered or lack a lot of knowledge. That's why any comment offering information whould be much appreciated.

 

Questions:

  1. How do I implement those methods?
  2. After that, how can I create my property and "correlate" it to the wrapper?
  3. If the above questions are wrong, what should I do to achieve my goal?
0 Likes
220 Views
5 Replies
Replies (5)
Message 2 of 6

daniel_cadext
Advisor
Advisor

There’s a sample at the swamp working with properties, not sure if it’s applicable  

https://www.theswamp.org/index.php?topic=59518.0

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx
0 Likes
Message 3 of 6

xgritsios
Explorer
Explorer

I studied the sample that you indicated and learned about the implementation of the OPM interface. Although there are a lot of useful information and code -that I wouldn't discover easily-, I cannot find code related to any kind of property dependency. Is there any way to make a property that holds values for every vertex of a polyline and displays these values depending on the "Current vertex" parameter? (just like the Vertex X and Vertex Y properties)

 

I am thinking of certain ways to achieve this. I am not sure if any of these are feasible by the way; I am describing the concept.

The proper way would be to use some available functionality that "connects" the new property to the current vertex property. If AutoCAD treats and stores vertices of polylines like individual AcDbObjects then it should be possible to obtain a pointer to the point entity that current vertex property indicates.

The rough way would be to make a property that updates itself with the corresponding value, every time the current vertex property changes. I am thinking of using reactors for this.

0 Likes
Message 4 of 6

daniel_cadext
Advisor
Advisor

I don’t know if there’s a way to hook in to the “Current Vertex” property field, I’ve never tried anything like that.  I’m guessing there is a way, example, for a custom object that derives from AcDbPolyline

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx
0 Likes
Message 5 of 6

xgritsios
Explorer
Explorer

Derive from AcDbPolyline and then what? Do you have anything in mind?

 

The problem is that I have to "hook" the new property on an already existing one. I have made many tries with custom objects but none seem to offer this functionality.

Can I at least be notified when the current vertex property changes and get its value? Would reactors help in any way?

0 Likes
Message 6 of 6

daniel_cadext
Advisor
Advisor

Yeah, sorry that was a dumb idea, I was thinking AcDbPolyline::getPointAt was virtual. You could always create a new “Current Vertex” property field in a new category.

 

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx
0 Likes