Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Creating a Field for a Lisp variable

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
honkinberry
2881 Views, 7 Replies

Creating a Field for a Lisp variable

I have been having incredible difficulty creating a Field for a Lisp variable.  Is this even actually possible?

Here's a simple example, in a fresh CAD session, create a piece of Mtext, and then fire this:

(setq v (vlax-ename->vla-object (entlast))
	
	_var001 "SAMPLE"

	c "%<\\AcVar.17.0 Lisp._var001>%"
) ; setq
(vlax-put-property v (quote TextString) c)

When I do that, I get just the #### in the Mtext.

If I double-click the field to bring up the dialog and click OK, then it displays.

 

But then the next issue - more often than not when I try to bring up the Field dialog for Lisp Variables, AutoCAD summarily crashes.  Like poof crashes, just completely goes away.  I do have about 7MB of custom Lisp code loaded, without with it doesn't crash.  Only mention that as it makes it more challenging to test.

 

But the primary issue, is that I can't seem to programmatically create a Field object scoped to a Lisp variable, unless the Field dialog has been opened to the Lisp variable section.  Which seems like a ridiculous requirement.

Any ideas out there?

 

--J

7 REPLIES 7
Message 2 of 8
dlanorh
in reply to: honkinberry

Works OK for me. I didn't get the "####". It just replaced the existing dummy textstring ("?") with the value, although I used

 

 

(vlax-put-property v 'textstring c)

 

 

 It did error when I tried a second time, i.e. replacing a field with a field. But work if I separated the two by replacing the first field with dummy text then the text with a second field

 

Edit: Two other points:

 

1. I forgot. I use "%<\\AcVar Lisp._var001>%" so it isn't tied to any ACAD version.

2. What happens when the variable falls out of scope. i.e. for a local variable the lisp ends or for a global autocad ends?

I am not one of the robots you're looking for

Message 3 of 8
honkinberry
in reply to: dlanorh

I can get it to occasionally work.  But it is not consistent.

After restarting, it will maybe work once.  Then restart CAD, and it's #### again.

I see exceptionally few examples of assigning Lisp variables to field objects, which leads me to believe that others have hit this same hurdle.

What is your version of CAD, and does this consistently work for you every time you restart CAD?

 

--J

Message 4 of 8
honkinberry
in reply to: honkinberry

Ah!  I'm on to something.

 

In a completely fresh CAD session (please just restart Windows, and open CAD to a completely blank drawing), I cannot add a Field to Mtext, of either Lisp Variable or Custom Drawing Property.  Always ####.

Using this:

; FIRST, manually create a piece of Mtext, then:

(setq v (vlax-ename->vla-object (entlast))
	_var001 "SAMPLE"
	c "%<\\AcVar.17.0 Lisp._var001>%"
) ; setq
(vlax-put-property v (quote TextString) c)

But then type FIELD to bring up the dialog box, and click Cancel.

Note, that original piece of Mtext cannot be fixed, so re-firing the above code now renders it to "----".

 

*BUT*, if you create a NEW piece of Mtext, it works fine.  In fact, this entire *session* of CAD is fine, this drawing can be closed, a new one created, repeat the above process, and it works!  But quit the CAD session completely and try again, same issue.

 

SO, what I need, what it seems ANY programmer needs, for the Lisp Variable feature to work for Fields, is some ability to fire whatever requery event occurs when the Dialog box opens.  Obviously only a *programmer* would be associating a Lisp variable with a Field, and would likely be doing it programmatically, not via the interface.  So can I get some recognition that this is a BUG, and hopefully some tips?

 

--J

Message 5 of 8
dlanorh
in reply to: honkinberry

I'm using 2012.

 

THIS may help

I am not one of the robots you're looking for

Message 6 of 8
honkinberry
in reply to: dlanorh

That post is not exactly relevant, however, the mention of the UPDATEFIELD command turns out to be the solution!

Go figure!

Thank you.  Hey, you've earned it, you can go ahead and upgrade your CAD now.  😉

 

--J

Message 7 of 8
mark.bollons
in reply to: honkinberry

Just to add that AutoCAD LT now has AutoLISP but vla- vlax- and vlr- have been excluded so this solution is not available to us poors. 

Message 8 of 8
a_klaverQHB9B
in reply to: honkinberry

I am a noob, but just tested the vla vlax... seems like it works.

Command: (setq ent(car(entsel)))
Select object: <Entity name: 17b2222f9e0>
Command: (setq vlaEnt(vlax-ename->vla-object ent))
#<VLA-OBJECT IAcadTable 0000017b493950a8>
Command: (vlax-dump-object vlaEnt t)
; IAcadTable: IAcadTable Interface
; Property values:
; AllowManualHeights = 0
; AllowManualPositions = 0

etc. etc.

 

EDIT: This should be a reply to mark.bollons ...

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

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report