Jump to content

help !! lisp code for quick dimension&column


git_thailand

Recommended Posts

need code 1. auto column on grid line intersection (in layer column) pic. 1

need code 2. select grid for auto dimension (in layer dimension) pic. 2

thank you.

 

1.jpg

2.jpg

Link to comment
Share on other sites

Let me take a wild guess here.

 

You would like someone to tell you how to go about either 1) finding a lisp routine that will do this or 2) how to write a lisp routine that will do this. Which is it?

 

It always helps to be as specific as one can be to avoid any confusion on what is being asked.

Edited by ReMark
Link to comment
Share on other sites

Here are two functions to get you started:

 

[color=GREEN];;----------------=={ Intersections in Set }==----------------;;[/color]
[color=GREEN];;                                                            ;;[/color]
[color=GREEN];;  Returns a list of all points of intersection between      ;;[/color]
[color=GREEN];;  objects in a selection set                                ;;[/color]
[color=GREEN];;------------------------------------------------------------;;[/color]
[color=GREEN];;  Author: Lee Mac, Copyright © 2011 - www.lee-mac.com       ;;[/color]
[color=GREEN];;------------------------------------------------------------;;[/color]
[color=GREEN];;  Arguments:                                                ;;[/color]
[color=GREEN];;  ss - SelectionSet                                         ;;[/color]
[color=GREEN];;------------------------------------------------------------;;[/color]
[color=GREEN];;  Returns:  List of intersection points, or nil             ;;[/color]
[color=GREEN];;------------------------------------------------------------;;[/color]

([color=BLUE]defun[/color] LM:IntersectionsInSet ( ss [color=BLUE]/[/color] i1 i2 ls o1 o2 )
   ([color=BLUE]repeat[/color] ([color=BLUE]setq[/color] i1 ([color=BLUE]sslength[/color] ss))
       ([color=BLUE]setq[/color] o1 ([color=BLUE]vlax-ename->vla-object[/color] ([color=BLUE]ssname[/color] ss ([color=BLUE]setq[/color] i1 ([color=BLUE]1-[/color] i1)))))
       ([color=BLUE]repeat[/color] ([color=BLUE]setq[/color] i2 i1)
           ([color=BLUE]setq[/color] o2 ([color=BLUE]vlax-ename->vla-object[/color] ([color=BLUE]ssname[/color] ss ([color=BLUE]setq[/color] i2 ([color=BLUE]1-[/color] i2))))
                 ls ([color=BLUE]append[/color] ls (LM:GroupByNum ([color=BLUE]vlax-invoke[/color] o1 'intersectwith o2 [color=BLUE]acextendnone[/color]) 3))
           )
       )
   )
   ls
)

[color=GREEN];;-----------------=={ Group by Number }==--------------------;;[/color]
[color=GREEN];;                                                            ;;[/color]
[color=GREEN];;  Groups a list into a list of lists, each of length 'n'    ;;[/color]
[color=GREEN];;------------------------------------------------------------;;[/color]
[color=GREEN];;  Author: Lee Mac, Copyright © 2010 - www.lee-mac.com       ;;[/color]
[color=GREEN];;------------------------------------------------------------;;[/color]
[color=GREEN];;  Arguments:                                                ;;[/color]
[color=GREEN];;  l - List to process                                       ;;[/color]
[color=GREEN];;  n - Number of elements by which to group the list         ;;[/color]
[color=GREEN];;------------------------------------------------------------;;[/color]
[color=GREEN];;  Returns:  List of lists, each of length 'n'               ;;[/color]
[color=GREEN];;------------------------------------------------------------;;[/color]

([color=BLUE]defun[/color] LM:GroupByNum ( l n [color=BLUE]/[/color] r)
   ([color=BLUE]if[/color] l
       ([color=BLUE]cons[/color]
           ([color=BLUE]reverse[/color] ([color=BLUE]repeat[/color] n ([color=BLUE]setq[/color] r ([color=BLUE]cons[/color] ([color=BLUE]car[/color] l) r) l ([color=BLUE]cdr[/color] l)) r))
           (LM:GroupByNum l n)
       )
   )
)

 

Carefully read the descriptions in the headers, including the arguments / returns.

 

With these, most of the hard work is already done, what remains for you to do:

 

  • Prompt the user for a Selection Set of Grid-lines

 

  • Pass the set to the appropriate function above

 

  • Iterate over the list of points returned, and insert a block at each point in the list.

Link to comment
Share on other sites

Since Lee Mac is no longer on-line, please find below an example of usage of his intersections finder:

 

(vl-load-com)
[color=blue]
;add Lee Mac's code here[/color]

(setq SelectionSet (ssget '((0 . "LINE"))))
(LM:IntersectionsInSet SelectionSet) 

Regards,

Mircea

Link to comment
Share on other sites

and how to auto column ???

 

This may get you started:

 

(vl-load-com)

[color=blue];add Lee Mac's code here[/color]

(setq SelectionSet (ssget '((0 . "LINE"))))
(setq PointsList (LM:IntersectionsInSet SelectionSet))

(setq OldOsmode (getvar "OSMODE"))   ;retain user setup
(setvar "OSMODE" 0)                  ;disable OSMODE
(foreach thePoint PointsList         ;add circles in each intersection
(command "_CIRCLE" thePoint 1.0))
(setvar "OSMODE" OldOsmode)          ;restore user setup

 

Regards,

Mircea

Link to comment
Share on other sites

and how to auto column ???

 

Did you read & understand what my functions are doing?

 

Think about how you would insert the Columns manually, and consider the functions 'foreach' and 'command'

Link to comment
Share on other sites

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