Jump to content

Call a LISP function


Titus25

Recommended Posts

Hello,

I'm very new to using LISP functions on Autocad/Civil 3D.

I need to create minimum bounding boxes around polylines.

 

I've loaded the LISP function created by Lee mac for this, via the

loadapp

command.

The function is loaded (Minimum Bounding Box.lsp successfully loaded).

 

My problem is simply how to call this function correctly?

When I type the command:

 (LM:minboundingbox sel 0.001)

 I get nil.

Do I need to install anything else first ? (it seems to be a subfunction)

What am I doing wrong?

 

Thanks for your answers.

 

Edited by Titus25
Link to comment
Share on other sites

If you look at the bottom of the page you linked to, there's some code that calls minboundingbox. The word sel refers to a variable that's defined earlier in the function, and that comes from a selection made by the user. So you can either create a function that calls minboundingbox, which you'll be able to use whenever you need it, or rewrite the freestanding command to call ssget as shown in Lee Mac's example.

 

If you need more help, ask away.

 

Welcome to the forum!

  • Like 1
Link to comment
Share on other sites

2 questions "minimum bounding boxes around polylines." Boxes implies a plural so multiple boxes required, polylines implies plural so do many.

 

Confirm 1 box of all polylines or a single box around 1 pline but repeated for all plines.

Edited by BIGAL
Link to comment
Share on other sites

My aim is to draw one single box around 1 pline but for all plines.

The above mentionned LISP function works well for 1 pline, but I have to call it once for each pline. Is there a way to automate the function to all selected plines ?

Link to comment
Share on other sites

Try this, can add ssget by layer, make on another layer etc.

(defun c:wow ( / ss obj pointmin pointmax)
(setq ss (ssget '((0 . "LWPOLYLINE"))))
(if (= ss nil)
(alert "No plines selected ")
(repeat (setq x (sslength ss))
(setq obj (vlax-ename->vla-object (ssname ss (setq x (1- x)))))
(vla-GetBoundingBox obj 'minpoint 'maxpoint)
(setq pointmin (vlax-safearray->list minpoint))
(setq pointmax (vlax-safearray->list maxpoint))
(command "rectang" pointmin pointmax)
)
)
(princ)
)
(c:wow)

image.png.7c5aec1fbfd4d363d325c54227b224e8.png

Edited by BIGAL
Link to comment
Share on other sites

Thanks for this code! It works well for many plines, but the bounding boxes are not oriented to the shape and thus not the real "minimum" bounding boxes.

Link to comment
Share on other sites

The bounding box function always provides a zero 90 orientation.

 

Ok a solution I am pretty sure was done by Lee-mac using a rotate box function. Your lucky I found it

 

Minimum Bounding Box | Lee Mac Programming (lee-mac.com)

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