Jump to content

Lisp to create a boundary around blocks that are not touching.


Recommended Posts

Posted

Dear Sir,

 

Can I have the lisp code , to draw outer line for the different objects which are not touching , please refer attached is the typical block which require the boundary line. I will perform multiple times daily for different shapes. Rectangle blocks shows in the attachments are the objects. Your time & help is well apprieciated.

 

Regards,

Saikiran Gone

saikiran.gone@gmail.com

Block Drawing.pdf

Posted (edited)

The intersectwith comes to mind, if always this type of pattern then multiples could be done, I take it they are plines touching. Do you want a outline or how many or both, then some form of export or table ? Need to know the answers so its not a case of some of us here adding on all the time. I have use a ht factor of +1 may need that to be changed.

 

Give this a try

(defun boxx (obj / )
(vla-GetBoundingBox obj 'minpoint 'maxpoint)
(setq pmin (vlax-safearray->list minpoint))
(setq pmax (vlax-safearray->list maxpoint))
)

(defun c:test ( / oldsnap obj topmax pmin pmax x )
(setq oldsnap (getvar 'osmode))
(setvar 'osmode 1)
(while (setq ent (entsel "pick top right corner"))
(setq obj (vlax-ename->vla-object (car ent)))
(boxx obj)
(setq topmax pmax)

(setvar 'osmode 0)

(setq ht (+ (- (cadr pmax)(cadr pmin)) 1))
(setq newpt (list ( car pmax )(- (cadr  pmax ) ht)))
(setvar 'osmode 512)
(setq x 1)
(while (/= (setq ss (ssget newpt)) nil)
    (setq obj (vlax-ename->vla-object (ssname ss 0)))
    (boxx obj)
    (setq newpt (list ( car pmax )(- (cadr  pmax ) ht)))
    (princ (setq x (+ x 1)))
)

(command "pline" topmax (list (car pmin)(cadr topmax)) pmin (list (car topmax)(cadr pmin)) "c")
(command "chprop" "last" "" "c" 1 "")
(setvar 'osmode 1)
)
(setvar 'osmode oldsnap)
(princ)
)

 

Edited by BIGAL
Posted
3 hours ago, BIGAL said:

The intersectwith comes to mind, if always this type of pattern then multiples could be done, I take it they are plines touching. Do you want a outline or how many or both, then some form of export or table ? Need to know the answers so its not a case of some of us here adding on all the time. I have use a ht factor of +1 may need that to be changed.

 

Give this a try


(defun boxx (obj / )
(vla-GetBoundingBox obj 'minpoint 'maxpoint)
(setq pmin (vlax-safearray->list minpoint))
(setq pmax (vlax-safearray->list maxpoint))
)

(defun c:test ( / oldsnap obj topmax pmin pmax x )
(setq oldsnap (getvar 'osmode))
(setvar 'osmode 1)
(while (setq ent (entsel "pick top right corner"))
(setq obj (vlax-ename->vla-object (car ent)))
(boxx obj)
(setq topmax pmax)

(setvar 'osmode 0)

(setq ht (+ (- (cadr pmax)(cadr pmin)) 1))
(setq newpt (list ( car pmax )(- (cadr  pmax ) ht)))
(setvar 'osmode 512)
(setq x 1)
(while (/= (setq ss (ssget newpt)) nil)
    (setq obj (vlax-ename->vla-object (ssname ss 0)))
    (boxx obj)
    (setq newpt (list ( car pmax )(- (cadr  pmax ) ht)))
    (princ (setq x (+ x 1)))
)

(command "pline" topmax (list (car pmin)(cadr topmax)) pmin (list (car topmax)(cadr pmin)) "c")
(command "chprop" "last" "" "c" 1 "")
(setvar 'osmode 1)
)
(setvar 'osmode oldsnap)
(princ)
)

 

Dear Bigal,

 

I need the one outer line for all the objects , please find the below drawing with the requirement explained.

 

Regards,

Saikiran Gone

Block Drawing-1.pdf

Posted

I am lazy... It would be better if you posted DWG instead of PDF...

Posted
15 hours ago, marko_ribar said:

I am lazy... It would be better if you posted DWG instead of PDF...

 

 

Please find Cad file as requested.

new block.dwg

Posted
9 hours ago, BIGAL said:

Seen this before 

Yes, I have gone through post in this link, but didn't get the required lisp code.

 

Posted

Ron's routine will do what you wanted on your example DWG... Why haven't you tested it? And plus it's reasonably fast, way faster than my versions...

Posted
12 minutes ago, marko_ribar said:

Ron's routine will do what you wanted on your example DWG... Why haven't you tested it? And plus it's reasonably fast, way faster than my versions...

Dear Marko,

 

I tried your code,  it is not developing the outer line what I required.

 

Regards,

Saikiran Gone.

Posted (edited)

Look at this capture.mp4... I don't have time to convert it to *.gif and it would look bad...

 

capture.zip

Edited by marko_ribar
Posted
1 hour ago, marko_ribar said:

Look at this capture.mp4... I don't have time to convert it to *.gif and it would look bad...

 

capture.zip 2.21 MB · 2 downloads

 

Dear Marko,

 

Thanks for your time & support. Well appreciated for sharing video to understand very clearly. Your small effort save my tons of working time .

 

I am getting small error in drawing the outline for the attached block, when I am trying on the different blocks . 

 

Regards,

Saikiran Gone.

 

 

Block_2.dwg

Posted

I get the same outline like it was already drawn... Should it be different? I mean, should it go around removed blocks at the gap looking from up to down of DWG? I don't think this is doable as gap is smaller than length of single block... Maybe if you try with smaller starting distance than block length - you have to try...

  • Like 1
Posted

Here is workaround... You have to temporarily fill middle hole with blocks and at the end, just remove them... Look into *.mp4...

capture.zip

Posted
15 hours ago, marko_ribar said:

Here is workaround... You have to temporarily fill middle hole with blocks and at the end, just remove them... Look into *.mp4...

capture.zip 1.44 MB · 6 downloads

HI Marko,

 

Thanks for support, your code is working if I select  lesser table length, in lieu of full length.

 

Regards,

Saikiran Gone. 

Posted (edited)
9 hours ago, BIGAL said:

marko MP4 not working ?

 

It is my slow PC - it has now 15 years or even more 20... Graphics card is very old NVIDIA GeForce 6600 GT... It is not possible to activate latest driver on Windows 10 as it crashes, so it must be disabled and that brings also problems with hardware acceleration in CAD... Capture is working, but as you can see it pauses with grabbing so it looks like it is not continuous grab... Sorry but that PC was available at the moment so I grabbed from it...

Edited by marko_ribar

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