Jump to content

Recommended Posts

Posted

Hello everyone, my name is Bruno and this is my first post here!!:)

 

Is important to say that I work with cad since 2014. I'm good in 2-D , and I have a little of experience in 3-D drawning. I'm sorry, but I've never used a Lisp.

 

 

This is what is happening:

I was teaching numerical integration to my brother using autocad. I made a drawning and divide it into ten equally spaced segments, as showed below.

 

figura oficial.jpg

 

 

I used " ID " to get the length of each chord, so I could paste into a excel sheet and calculate the area.

 

My doubt is: Is there any way to get the ID of multiple lines without click one by one?

This is fine when you divide a drawning into 100 , 1000 or 1 000 000 of spaces.

 

Cheers!!

Posted

Hi Bruno,

You could use "point manager" from Lee Mac to get the coordinates of the intersection points (ofcourse you would need 2nd lisp to place those point objects at each intersection),

or if you want directly to check the area - create a hatch or bpoly and look into its properties.

Posted

Welcome to CADTutor Bruno!

 

Please try the following:

[color=GREEN];; Integration Demonstration  -  Lee Mac[/color]

([color=BLUE]defun[/color] c:integrate ( [color=BLUE]/[/color] *error* axs crv csv des dis inc int lst num obj pt1 rtn tmp )

   ([color=BLUE]defun[/color] *error* ( msg )
       ([color=BLUE]if[/color] ([color=BLUE]and[/color] ([color=BLUE]=[/color] 'ename ([color=BLUE]type[/color] tmp)) ([color=BLUE]entget[/color] tmp)) ([color=BLUE]entdel[/color] tmp))
       ([color=BLUE]if[/color] ([color=BLUE]=[/color] 'file ([color=BLUE]type[/color] des)) ([color=BLUE]close[/color] des))
       ([color=BLUE]if[/color] ([color=BLUE]not[/color] ([color=BLUE]wcmatch[/color] ([color=BLUE]strcase[/color] msg [color=BLUE]t[/color]) [color=MAROON]"*break,*cancel*,*exit*"[/color]))
           ([color=BLUE]princ[/color] ([color=BLUE]strcat[/color] [color=MAROON]"\nError: "[/color] msg))
       )
       ([color=BLUE]princ[/color])
   )
   
   ([color=BLUE]if[/color] ([color=BLUE]and[/color] ([color=BLUE]setq[/color] crv (integrate:select [color=MAROON]"\nSelect curve to 'integrate': "[/color]))
            ([color=BLUE]setq[/color] axs (integrate:select [color=MAROON]"\nSelect axis: "[/color]))
       )
       ([color=BLUE]progn[/color]
           ([color=BLUE]initget[/color] 6)
           ([color=BLUE]setq[/color] num ([color=BLUE]cond[/color] (([color=BLUE]getint[/color] [color=MAROON]"\nSpecify number of divisions <10>: "[/color])) (10))
                 dis ([color=BLUE]vlax-curve-getdistatparam[/color] axs ([color=BLUE]vlax-curve-getstartparam[/color] axs))
                 inc ([color=BLUE]/[/color] ([color=BLUE]-[/color] ([color=BLUE]vlax-curve-getdistatparam[/color] axs ([color=BLUE]vlax-curve-getendparam[/color] axs)) dis) num)
                 obj ([color=BLUE]vlax-ename->vla-object[/color] crv)
           )
           ([color=BLUE]repeat[/color] ([color=BLUE]1+[/color] num)
               ([color=BLUE]if[/color] ([color=BLUE]setq[/color] pt1 ([color=BLUE]vlax-curve-getpointatdist[/color] axs dis))
                   ([color=BLUE]progn[/color]
                       ([color=BLUE]setq[/color] tmp
                           ([color=BLUE]entmakex[/color]
                               ([color=BLUE]list[/color]
                                  '(0 . [color=MAROON]"LINE"[/color])
                                   ([color=BLUE]cons[/color] 10 pt1)
                                   ([color=BLUE]cons[/color] 11
                                       ([color=BLUE]mapcar[/color] '[color=BLUE]+[/color] pt1
                                           (   ([color=BLUE]lambda[/color] ( v ) ([color=BLUE]list[/color] ([color=BLUE]-[/color] ([color=BLUE]cadr[/color] v)) ([color=BLUE]car[/color] v)))
                                               ([color=BLUE]vlax-curve-getfirstderiv[/color] axs ([color=BLUE]vlax-curve-getparamatdist[/color] axs dis))
                                           )
                                       )
                                   )
                               )
                           )
                       )
                       ([color=BLUE]if[/color]
                           ([color=BLUE]setq[/color] int
                               ([color=BLUE]vlax-invoke[/color] obj 'intersectwith
                                   ([color=BLUE]vlax-ename->vla-object[/color] tmp) [color=BLUE]acextendotherentity[/color]
                               )
                           )
                           ([color=BLUE]progn[/color]
                               ([color=BLUE]setq[/color] lst ([color=BLUE]cons[/color] ([color=BLUE]distance[/color] pt1 int) lst))
                               ([color=BLUE]entmake[/color] ([color=BLUE]list[/color] '(0 . [color=MAROON]"LINE"[/color]) '(62 .  ([color=BLUE]cons[/color] 10 pt1) ([color=BLUE]cons[/color] 11 int)))
                           )
                       )
                       ([color=BLUE]entdel[/color] tmp)
                   )
               )
               ([color=BLUE]setq[/color] dis ([color=BLUE]+[/color] dis inc))
           )
           ([color=BLUE]if[/color] ([color=BLUE]setq[/color] lst ([color=BLUE]reverse[/color] lst))
               ([color=BLUE]if[/color] ([color=BLUE]and[/color] ([color=BLUE]setq[/color] csv ([color=BLUE]vl-filename-mktemp[/color] [color=MAROON]"int"[/color] ([color=BLUE]getvar[/color] 'dwgprefix) [color=MAROON]".csv"[/color]))
                        ([color=BLUE]setq[/color] des ([color=BLUE]open[/color] csv [color=MAROON]"w"[/color]))
                   )
                   ([color=BLUE]progn[/color]
                       ([color=BLUE]write-line[/color] [color=MAROON]"Length 1,Length 2,Segment Width,Segment Area"[/color] des)
                       ([color=BLUE]setq[/color] rtn
                           ([color=BLUE]mapcar[/color]
                              '([color=BLUE]lambda[/color] ( a b [color=BLUE]/[/color] x )
                                   ([color=BLUE]write-line[/color]
                                       ([color=BLUE]strcat[/color]
                                           ([color=BLUE]rtos[/color] a 2 3) [color=MAROON]","[/color]
                                           ([color=BLUE]rtos[/color] b 2 3) [color=MAROON]","[/color]
                                           ([color=BLUE]rtos[/color] inc 2 3) [color=MAROON]","[/color]
                                           ([color=BLUE]rtos[/color] ([color=BLUE]setq[/color] x ([color=BLUE]*[/color] inc 0.5 ([color=BLUE]+[/color] a b))) 2 3)
                                       )
                                       des
                                   )
                                   x
                               )
                               lst ([color=BLUE]cdr[/color] lst)
                           )
                       )
                       ([color=BLUE]write-line[/color] [color=MAROON]""[/color] des)
                       ([color=BLUE]write-line[/color] ([color=BLUE]strcat[/color] [color=MAROON]",,Total Area:,"[/color] ([color=BLUE]rtos[/color] ([color=BLUE]apply[/color] '[color=BLUE]+[/color] rtn) 2 3)) des)
                       ([color=BLUE]setq[/color] des ([color=BLUE]close[/color] des))
                       ([color=BLUE]if[/color] ([color=BLUE]findfile[/color] csv) ([color=BLUE]startapp[/color] [color=MAROON]"explorer"[/color] csv))
                   )
                   ([color=BLUE]princ[/color] [color=MAROON]"\nUnable to generate CSV file."[/color])
               )
               ([color=BLUE]princ[/color] [color=MAROON]"\nNo intersection data found."[/color])
           )
       )
   )
   ([color=BLUE]princ[/color])
)
([color=BLUE]defun[/color] integrate:select ( msg [color=BLUE]/[/color] ent )
   ([color=BLUE]while[/color]
       ([color=BLUE]progn[/color] ([color=BLUE]setvar[/color] 'errno 0) ([color=BLUE]setq[/color] ent ([color=BLUE]car[/color] ([color=BLUE]entsel[/color] msg)))
           ([color=BLUE]cond[/color]
               (   ([color=BLUE]=[/color] 7 ([color=BLUE]getvar[/color] 'errno))
                   ([color=BLUE]princ[/color] [color=MAROON]"\nMissed, try again."[/color])
               )
               (   ([color=BLUE]null[/color] ent)
                   [color=BLUE]nil[/color]
               )
               (   ([color=BLUE]vl-catch-all-error-p[/color] ([color=BLUE]vl-catch-all-apply[/color] '[color=BLUE]vlax-curve-getendparam[/color] ([color=BLUE]list[/color] ent)))
                   ([color=BLUE]princ[/color] [color=MAROON]"\nInvalid object selected."[/color])
               )
           )
       )
   )
   ent
)
([color=BLUE]vl-load-com[/color]) ([color=BLUE]princ[/color])

Posted

A property of pline is area so why not make the shape a closed pline ? Use List or Properties to see area

Posted
A property of pline is area so why not make the shape a closed pline ? Use List or Properties to see area

 

Retrieving the enclosed area is of course very easy - I believe the OP is instead looking to demonstrate the convergence on the true area value as the number of divisions increases and the chords better approximate the curve (i.e. a graphical demonstration of integration from first principles).

Posted

Hi guys, thank you all for your support!!!

 

I believe the OP is instead looking to demonstrate the convergence on the true area value as the number of divisions increases and the chords better approximate the curve (i.e. a graphical demonstration of integration from first principles).

Yes Lee Mac, this is exactly what I want!! Your code is almost there, but is not exactly like this... the code have to execute something like Grrr said. The Lisp have to:

 

1-) Ask for the Lines. (I mean, "select the lines", something like that, where Lines = Chords cian/blue on my first picture, above)

 

2-) Execute the ID command over each line, at the intersect point. (The goal here is to Copy the information to paste into a word file)

 

Take a look on this video. I made everything manually. I belive that It Will clear the Ideas :)

 

 

 

Ps- I'm from Brazil. Here we use "Comma" instead of "Dot" and this is what I did in the video after paste in Word File.

Posted
Why not use the CSV file data generated by my program?

 

 

Is like I said, your code is really almost there, I really liked it! I Loved the fact that the final file is a CSV file!!! So please, what I'd like to ask you to improve in the original code (if possible) are 2 things:

 

1- ) The results are showed with 3 decimal plates... I'd like 4 ;

2- ) When the CSV file data is created, I'd like that you add one line more, containing the last lenght of all, like this example:

 

 

Length_1 , Length_2 ,... etc

Length_2 , Length_3 , ...etc

Length_3 , Length_4 , ...etc

Length_4

 

Total area ...etc

 

 

 

 

Thank you again for your help! you have no idea how you are helping me!! :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...