Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Valued Contributor
Shinigami_black
Posts: 60
Registered: ‎06-21-2012
Message 1 of 17 (236 Views)

LISP problem in function

236 Views, 16 Replies
07-28-2012 07:59 AM
Hi, I'm new to lisp programing, I had programed in C++ and now need to make lisp program for AutoCAD Civil 3D 2010 to automate my work. But have some problems. My program gets all vertexes of polyline and calculate points on polyline in given distance. But when I run program and select polyline it gets me wrong points and if I try second time it gives me slightly different points on same polyline. So I do not get why it do it. I had attached lsp file.
Valued Contributor
Shinigami_black
Posts: 60
Registered: ‎06-21-2012
Message 2 of 17 (233 Views)

Re: LISP problem in function

07-28-2012 08:21 AM in reply to: Shinigami_black

Attachment

Valued Contributor
Shinigami_black
Posts: 60
Registered: ‎06-21-2012
Message 3 of 17 (226 Views)

Re: LISP problem in function

07-28-2012 09:48 AM in reply to: Shinigami_black

I found problem in point calculation. I need to add one line in function da_SetPointsOnPolyline

this line

(setq piece_length (- piece_length segment))

after line

(setq points_coordinates (list (list xy (car new_list))))

 

And I have a guess about puting circles in defferent places in second try of runing function. But I am not guaranteed.

I guess it was an Object Snap work. :smileyfrustrated:

As it puts circles in wrong places if it is turned on. Need to find how to turn it off in program run time.

Mentor
devitg
Posts: 1,705
Registered: ‎03-14-2004
Message 4 of 17 (223 Views)

Re: LISP problem in function

07-28-2012 10:47 AM in reply to: Shinigami_black

Please upload your sample dwg

Valued Contributor
Shinigami_black
Posts: 60
Registered: ‎06-21-2012
Message 5 of 17 (221 Views)

Re: LISP problem in function

07-28-2012 11:03 AM in reply to: devitg

It is standard dwg after Civil install and drawn LWPOLYLINE.

Now it works, after adding one line, previously mentioned, and turning off Osnap with (setvar "osmode" 0).

Unknown behavior of software makes your programing nightmare :smileyfrustrated:

 

And to add to what I am making.

It will drow slope between to polylines. In 3 different paterns. And without intersecting of patern.

 

 

P.S. I get this message after I copy - past from google translate to "Reply to Message" window

Your post has been changed because invalid HTML was found in the message body. The invalid HTML has been removed. Please review the message and submit the message when you are satisfied.

 


Mentor
devitg
Posts: 1,705
Registered: ‎03-14-2004
Message 6 of 17 (220 Views)

Re: LISP problem in function

07-28-2012 11:22 AM in reply to: devitg
Do a browse to VLxxx functions , specially vlax-curve-getPointAtDist and all family off VLAX-CURVE
Mentor
devitg
Posts: 1,705
Registered: ‎03-14-2004
Message 7 of 17 (219 Views)

Re: LISP problem in function

07-28-2012 11:34 AM in reply to: Shinigami_black

Any time you use NATIVE command , you shall set osmode and orthomode to 0 , except if you really want to SNAP to a certain place .

 

 

 

(command "LINE" "mid" pause pause "") It will start a LINE at a MID off a Enty .

 

 

And better use RICH text , but leave more than 2 lines "betveen"  lines

 

 

And DO NOT USE EMOTICONS , it is a place for noemoticon people .
Valued Contributor
Shinigami_black
Posts: 60
Registered: ‎06-21-2012
Message 8 of 17 (218 Views)

Re: LISP problem in function

07-28-2012 12:04 PM in reply to: devitg

Thanks devitg


vlax-curve-getPointAtDist is just what I needed, but I already made a function to do it. Now I need to make a function to find point in second polyline where perpendicular line from first polyline intersects with second polyline. I have a way to do it using geometry formulas, need to creat lisp functions.


I had saw vlxx functions several times, but did not know which language it is autolisp or other.

 

Any time you use NATIVE command , you shall set osmode and orthomode to 0 , except if you really want to SNAP to a certain place .

 

Found it hard way :smileyfrustrated:

 

(command "LINE" "mid" pause pause "")  what pause do?


*Expert Elite*
Kent1Cooper
Posts: 5,796
Registered: ‎09-13-2004
Message 9 of 17 (212 Views)

Re: LISP problem in function

07-28-2012 02:22 PM in reply to: Shinigami_black

Shinigami_black wrote:

.... I need to make a function to find point in second polyline where perpendicular line from first polyline intersects with second polyline. I have a way to do it using geometry formulas, need to creat lisp functions.
....


Look into the (vlax-curve-getClosestPointTo) function.  Or, if the "perpendicular line" is an actual Line entity, search this Discussion Group for examples of (vla-intersectwith).

Kent Cooper
Mentor
devitg
Posts: 1,705
Registered: ‎03-14-2004
Message 10 of 17 (206 Views)

Re: LISP problem in function

07-28-2012 03:01 PM in reply to: Shinigami_black

Pause: allow or do a "pause" to user input .

 

 

Maybe, if you put in clear WHAT do you need to do , or the FINAL TASK or Purpose , instead of show us HOW you are doing it , you could get better and wide help.

 

Also you use a reserved word or a Function name as a variable "DISTANCE"

 

Lisp and VLisp are similar , they share all the LISP functions +  adapted from VBA .

 

Your first DEFUN

 

could be just 

 

 

(defun da_GetLengthBetweenTwoPoints (point1 point2 )
(distance point1 point2)
)

 

Seem to be you do not  use the VLIDE , the Vlisp editor , it came inside the ACAD .

 

 

 

 

 

 

 

 

 

 

 

 

 

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!