Hello.
I find that implementing dxfInFields() for a custom entity enables modification of entity member vars through Lisp (subst, entmod).
Is this Kosher and Is there some documentation about it?
Thanks
alex
Solved! Go to Solution.
Solved by artc2. Go to Solution.
Yes, that's how it's designed. (entmake), (entmod), (entget), and the corresponding functions in ARX use a bagfiler (filer type AcDb::kBagFiler) to read/write the data via dxfInFields()/dxfOutFields(). This is documented in the ObjectARX Developers Guide (at least it used to be).
if you want to disallow this, then you can look at the filer type in your dxfInFields()/dxfOutFields() methods and return an error if the filer type is AcDb::kBagFiler.
Thank you Art.
One additional question:
If the custom entity contains two (or more) strings, both filed out with kDxfText, so both (assoc 1), how can we access them and tell them apart in Lisp?
For that matter, looking at the list returned by (entget), we see two groups (assoc 100): one with the base class name and one with the derived class name. How do we tell them apart? (assoc) returns only the first group.
alex
Thank you for replying.
I get this:
Command: Q2
; error: bad argument type: stringp nil
I have no knowledge in VisualLisp.
Maybe some explanations?
Here it is:
((-1 . <Entity name: 7efb94c8>) (0 . MYENT) (330 . <Entity name:
7efb7cf8>) (5 . 1E1) (100 . AcDbEntity) (67 . 0) (410 . Model) (8 . 0) (100 .
MYENT) (10 1120.0 974.0 0.0) (40 . 1.0) (41 . 1.0) (50 . 0.0) (1 . My Text))
For that list you can extract the string value of the DXF 1 with:
i.e. your list was extracted with:
Command: (setq ename (car (entsel "\nSelect my custom object: ")))
Command: (setq lst (entget ename))
Command: (setq dxf1 (cdr (assoc 1 lst)))
"My Text"
Command:
HTH.
I know that 🙂
The question was: if we need - in the same custom entity - two strings, each filed out with dxf code 1, how do we access them from Lisp. (cdr assoc 1 returns only the 1st one).
As an example, I posted the (entget) of a custom entity which has two dxf 100 groups.
I see, I only saw one (and my lisping is out of date)... anyway here is one way:
(foreach dxf (entget ename) (if (= 1 (car dxf)) (setq l (append l (list (cdr dxf))))))
HTH.
OK, but it relies on a particular ordering of the data.
I was looking for a way of designing the custom entity so as to diferrentiate the data having the same dxf code, for a safer access from lisp (safer than relying on the data ordering).
Could one use different dxf codes for what is essentially the same thing (like the first string dxf 1, the 2nd string dxf 2, etc.) If I understand it correctly, it says so in the ARX documentation 'DXF Group Ranges'.
When using repeating group codes, you must rely on the ordering (AutoCAD's built-in objects that use repeating group codes all rely on order), unless you embed something in the actual data to allow you to differntiate (I've never seen that done).
Sure you can use different group codes, and that is the easiest way to do things when possible. But, there are only so many for each data type, so if you have more data items then available group codes for a specific data type, then you have to use repeating group codes.
Specifically we need three strings, so the range given for texts (I see there are 19 values in 4 groups) is more than enough.
I just wasn't sure I understood the doc correctly.
Thanks for clarifying the issue.
BTW, is there any differrence between the groups?
I'm not sure I understand what you mean by "the groups". If you mean is there a difference between using two group codes in the same data type range, for example, using dxf group code 1 and dxf group code 2, then no, there is no difference.
From the docs: DXF Group Code Ranges for Text: 1-4; 6-9; 102; 300-309;
What I meant is any differrrence between these ranges.
1-4, 6-9, and 300 - 309 no difference. Group 102 is specifically for control strings (i.e. they start with "{" or "}") and should not be used for anything else.