AI generated lisp not working

AI generated lisp not working

venturini.anthony
Advocate Advocate
2,650 Views
8 Replies
Message 1 of 9

AI generated lisp not working

venturini.anthony
Advocate
Advocate

I asked chatgpt to make this lisp. can anyone help why its giving me an error?

 

(vl-load-com)
(defun c:altp ( / ent label align)
(setq ent (car (entsel "Select polyline to align label to: ")))
(setq label (car (entsel "Select label to align: ")))
(setq align (vlax-invoke ent 'GetAlignmentPoint))
(vlax-put-property label 'AlignmentPoint align)
(princ)
)

0 Likes
2,651 Views
8 Replies
Replies (8)
Message 2 of 9

marko_ribar
Advisor
Advisor

Change this :

(setq align (vlax-invoke ent 'GetAlignmentPoint))

To :

(setq align (vlax-invoke (vlax-ename->vla-object ent) 'GetAlignmentPoint))

 

And this :

(vlax-put-property label 'AlignmentPoint align)

To :

(vlax-put-property (vlax-ename->vla-object label) 'AlignmentPoint align)

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 3 of 9

venturini.anthony
Advocate
Advocate

i did that and i got this message 

venturinianthony_0-1674490228278.png

 

0 Likes
Message 4 of 9

marko_ribar
Advisor
Advisor

Polylines don't have alignment point property - they have vertices and segments (straight or arced-if lwpolyline)...

You have to decide where you want to put label (I suppose some "*TEXT" entity...)

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 5 of 9

Kent1Cooper
Consultant
Consultant

Once you've determined how to specify the where, there's the question of how to put the label there.  What kind of object is the "label"?  If it's Mtext or plain Text, there's a VLA property called InsertionPoint -- is that what you need instead of AlignmentPoint?

Kent Cooper, AIA
0 Likes
Message 6 of 9

marko_ribar
Advisor
Advisor

I was going to suggest you these 2 links :

http://www.lee-mac.com/curvealignedtext.html 

http://www.lee-mac.com/dtcurve.html 

 

HTH.

M.R.

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 7 of 9

Kent1Cooper
Consultant
Consultant

@venturini.anthony wrote:

I asked chatgpt to make this lisp.....


Maybe that's the problem.  The >Wikipedia article about ChatGPT< includes this:

'Its uneven factual accuracy was identified as a significant drawback.'

and

'ChatGPT suffers from multiple limitations. OpenAI acknowledged that ChatGPT "sometimes writes plausible-sounding but incorrect or nonsensical answers".'

Kent Cooper, AIA
Message 8 of 9

greg_battin
Advocate
Advocate

The only thing that I found helpful with chatgpt is to have it explain a portion of code to me.

 

If I want to understand some code, I enter 'autolisp and then the code'. For example, I would enter:
"autolisp (or (wcmatch AVER "*17*") (wcmatch AVER "*18*"))"

and the response from chatgpt is:

"The ssget function in AutoLISP is used to select sets of objects in AutoCAD based on certain criteria. The first argument "x" is the selection set name, and the second argument is a list of filter criteria. In this example, the filter criteria is set to select objects with a layer property of "0". The number 8 represents the layer property in the AutoCAD database, and the string "0" represents the desired value for that property. The function will return a list of object handles for all objects in the drawing that meet the specified criteria."

 

For now, I will use it for that purpose and not have it write code for me.

I think that is pretty cool. I don't have to make a post on the forums asking someone to explain some basic code to me.

Message 9 of 9

Kent1Cooper
Consultant
Consultant

@greg_battin wrote:

....If I want to understand some code, I enter 'autolisp and then the code'. For example, I would enter:

"autolisp (or (wcmatch AVER "*17*") (wcmatch AVER "*18*"))"

and the response from chatgpt is:

"The ssget function ....


Does it really tell you about (ssget) when your entry involves (wcmatch)?  That doesn't seem so cool to me.

And does the >AutoLisp Functions Reference< not explain things well enough?

Kent Cooper, AIA
0 Likes