ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Lisp access to custom entity data

17 REPLIES 17
SOLVED
Reply
Message 1 of 18
alex_b
1760 Views, 17 Replies

Lisp access to custom entity data

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

17 REPLIES 17
Message 2 of 18
artc2
in reply to: alex_b

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.

Message 3 of 18
alex_b
in reply to: artc2

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

Message 4 of 18
diagodose2009
in reply to: alex_b

Try my program , for scan object in AutoCAD R14..

Enter command at textscreen... Q2[enter]

Downloading...

 

 

 

Message 5 of 18
alex_b
in reply to: diagodose2009

Thank you for replying.

 

I get this:

 

Command: Q2
; error: bad argument type: stringp nil

 

I have no knowledge in VisualLisp.

Maybe some explanations?

 

 

Message 6 of 18
diagodose2009
in reply to: alex_b

Please send email to... or contact us at... Downloading
Message 7 of 18
LE3
Advocate
in reply to: alex_b

Post the entget return here.

Message 8 of 18
alex_b
in reply to: LE3

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))

Message 9 of 18
LE3
Advocate
in reply to: alex_b

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.

Message 10 of 18
alex_b
in reply to: LE3

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.

 

Message 11 of 18
LE3
Advocate
in reply to: alex_b

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.

 

 

Message 12 of 18
alex_b
in reply to: LE3

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'.

 

Message 13 of 18
artc2
in reply to: alex_b

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.

Message 14 of 18
alex_b
in reply to: artc2

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?

 

 

Message 15 of 18
artc2
in reply to: alex_b

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.

Message 16 of 18
alex_b
in reply to: artc2

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.

 

Message 17 of 18
artc2
in reply to: alex_b

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.

Message 18 of 18
alex_b
in reply to: artc2

Now it's perfect.

Thank you.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost