๐Ÿ™๐Ÿฟ How to redraw the block of a neighborhood when selecting

๐Ÿ™๐Ÿฟ How to redraw the block of a neighborhood when selecting

arperezinf
Advocate Advocate
2,133 Views
27 Replies
Message 1 of 28

๐Ÿ™๐Ÿฟ How to redraw the block of a neighborhood when selecting

arperezinf
Advocate
Advocate

Hello ๐Ÿ‘‹๐Ÿ˜€

 

I am trying to create a lisp routine that when selecting a block of a neighborhood the same block of the neighborhood is drawn but on top of the previous one, in several separate polylines using the name layer: L1RF, color: Yellow.

 

Then I need them to be offset by giving these two distance options (3.25 or 2) and ask where the offset is going to be, if inside or outside and when they are created using the name layer: L2AI color: 30.

 

I did this, but I do not want to select the corners of the block, I wish that when selecting the whole process to be executed previously explain.

 

(setq pt1 (getpoint "\nFirst point:"))
(setq pt2 (getpoint "\nSecond point:"))
(setq pt3 (getpoint "\nThird point:"))
(setq pt4 (getpoint "\nFourth point:"))
(command "_pline" pt1 pt2 "")
(command "_pline" pt2 pt3 "")
(command "_pline" pt3 pt4 "")
(command "_pline" pt4 pt1 "")
(command "_offset")

 

 

arpsolidworks.gif

 

I hope you understand me, ask any questions.

Thank you very much for reading my message.

Greetings. 

0 Likes
2,134 Views
27 Replies
Replies (27)
Message 2 of 28

john.uhden
Mentor
Mentor

I would use my own XOFFSET program which gives you options for the offset's layer, color, etc. and whether to offset just one segment of a polyline or the whole thing.  You have to remember to set OFFSETGAPTYPE appropriately before running, unless you enter an offset distance of 0, which is for cloning.

John F. Uhden

0 Likes
Message 3 of 28

ronjonp
Mentor
Mentor

This still needs some work but should be a good start for you:

(defun c:foo (/ a b d e ex k o of)
  (defun _boundary (p l c / e)
    (if	p
      (progn (setq e (entlast))
	     (command "_.-boundary" p "")
	     (if (not (equal e (entlast)))
	       (progn (entmod (append (entget (entlast)) (list (cons 8 l) (cons 62 c)))) (entlast))
	     )
      )
    )
  )
  (if (and (setq d (getdist "\nEnter offset distance: "))
	   (progn (initget 0 "IN OUT") (setq k (getkword "\nOffset IN or OUT: ")))
	   (setq k (cond ((= k "OUT")-1)(1)))
	   (setq d (* k d))
      )
    (progn (while (setq e (_boundary (getpoint "\nPick internal point: ") "L1RF" 2))
	     (cond ((and (setq o (vlax-ename->vla-object e))
			 ;; (setq of (car (vlax-invoke o 'offset 2)))
			 ;; (setq a (vlax-curve-getarea of))
			 (setq ex (vlax-invoke o 'explode))
		    )
		    ;; This check does not work for the exploded lines created
		    ;; (cond ((< (vlax-curve-getarea of) (vlax-curve-getarea e)) (setq d (* -1 d))))
		    (foreach l ex
		      (setq b (car (vlax-invoke l 'offset d)))
		      (entmod (append (entget (vlax-vla-object->ename b)) '((8 . "L2AI") (62 . 30))))
		    )
		    (vla-delete o)
		   )
	     )
	   )
    )
  )
  (princ)
)

2021-12-29_13-17-43.gif

0 Likes
Message 4 of 28

john.uhden
Mentor
Mentor

@ronjonp 

Here we go with the INSIDE vs. OUTSIDE dilemma again.  It depends on whether the figure is drawn CW (-) or CCW (+), which can be determined by summing all the deflections around the figure.  If minus then CW; if plus then CCW.  If CW then outside offset is -; if CCW then outside offset is +.

John F. Uhden

0 Likes
Message 5 of 28

ronjonp
Mentor
Mentor

@john.uhden 

Yup which works on the original polyline .. but a quick test after exploding reversed and unreversed the lines did not honor the original direction. Give it a test if you have time.

0 Likes
Message 6 of 28

Sea-Haven
Mentor
Mentor

My $0.05 as before a bpoly if you use vla-offset a +offset is left -ve is right, so no need for a in or out question. The bpoly is made CCW so it would make sense to reverse the poly so +ve is out which matches the human thinking. This idea will reduce the code slightly.

0 Likes
Message 7 of 28

john.uhden
Mentor
Mentor
@Sea-Haven
Ahem. If a BPOLY is always made CCW then - is to the inside and + is to
the outside. But that does surely save steps.

John F. Uhden

0 Likes
Message 8 of 28

arperezinf
Advocate
Advocate

Hello @john.uhden @ronjonp @Sea-Haven ๐Ÿ˜€๐Ÿ‘‹

 

Sorry for the delay in responding to your comments.

 

I tried the function several times, but it does not work for me, close the AutoCad Map 3D 2021 software. ๐Ÿ˜ญ๐Ÿ˜ข

 

I explain why I suppose the lisp routine doesn't work for me.

 

I work on with a gis software, the blocks and streets are blocks called "SPRBLOCK". I have no idea why it is called like that, nor do I have access to the code of the gis program, nor to the codes of the lisp commands of the gis software to give you more information.

 

Another thing, do not look at the AutoCad software, or the versions, it does not matter, because since 2016 they all work with this gis software that I use.

 

Would there be some way to tell the lisp code to only select only the "SPRBLOCK" elements, to see if it works like this.

 

Thank you very much for reading my message.
Greetings.

0 Likes
Message 9 of 28

ronjonp
Mentor
Mentor

@arperezinf Post a sample drawing.

0 Likes
Message 10 of 28

arperezinf
Advocate
Advocate

Hello @ronjonp 

 

I would like to be able to publish an example plan but it is useless because the gis program is necessary to load the data (Names, ID, data, values, etc.) of the elements of the plan.

 

If you open the map without the gis program, it gives an error. I can show you for example the data that I get when I use the "LIST" command to see the information of the elements.

 

If I execute the "LIST" command on a block or street in the map, it shows me these data:

arpsolidworks with the gis program.gif

If I open the cad without the gis program and execute the command "LIST" on a block or street of the plane, it shows me these data:

arpsolidworks without the gis program.gif

Thank you very much for reading my message.
Greetings.

0 Likes
Message 11 of 28

john.uhden
Mentor
Mentor

@arperezinf 

Please try using the following command function on one or more parts of your block (with GIS loaded).  It may reveal data that we can use.  Obviously paste the results into a response.

;;---------------------------------------------------
;; Command to "dump" ActiveX data of a nested object:
;;
(defun C:NOD ()
  (and
    (setq e (car (nentsel)))
    (setq object (vlax-ename->vla-object e))
    (vlax-dump-object object)
    (textscr)
  )
  (princ)
)

 

John F. Uhden

0 Likes
Message 12 of 28

diagodose2009
Collaborator
Collaborator

Clipboard.jpgYour source.lisp is very good, at means very stable.

You  see the file source

 

ronjonp_entsel
ronjonp_explode
ronjonp_offset

 

 

 

(Defun ronjonp_offset(expsrv newlayer jdcolor / item $rr nop dof old cnt)
 (setq;|a16965239|;
	 cnt 0
	 old (getvar (jc_cws12 283 10))) (php_echo (list (jc_cws12 293 23) old (jc_cws12 316 30))) (setq;|a16965404|;
	 dof (getdist "=")) (setq;|a171906488|;
	 dof (if (=  dof nil) old dof)) (if (not (zerop dof)) (foreach item expsrv (setq;|a1781014545|;
	 $rr (car (vlax-invoke item (read (jc_cws12 298 6)) dof))
	 nop (if (and  $rr newlayer) (vla-put-layer $rr newlayer) nil)
	 cnt (if $rr (+ cnt 1) cnt)
	 nop (if (and  $rr jdcolor) (vla-put-color $rr jdcolor) nil)))) (if cnt (setvar (jc_cws12 283 10) dof)) 
$rr)
(Defun dfn_ent_explodelist(objsel / $rr rstr)
 (setq;|a000|;
	 rstr (read (jc_cws12 346 7))
	 $rr (vlax-invoke objsel rstr)) 
$rr)

(Defun ronjonp_explode(acblockRes / $rr objsel rstr z80 osk upx) 
 (setq;|a67117372|;
	 objsel (vlax-ename->vla-object acblockRes)
	 fns nil) (setq;|a16963240|;
	 z80 (jc_cws12 353 11)) (command (jc_cws12 364 5) acblockRes "" z80 z80) (command) (setq;|a000|;
	 osk (entlast)) (setq;|a000|;
	 rstr (read (jc_cws12 346 7))) (setq;|a165563660|;
	 upx (vlax-invoke objsel rstr)) (setq;|a000|;
	 $rr nil) (if (/= osk (entlast)) (foreach item upx (setq;|a000|;
	 $rr (cons item $rr)))) 
$rr)

 

 

0 Likes
Message 13 of 28

diagodose2009
Collaborator
Collaborator

You run the application "pp_blockgroupexp_jc10aro.lsp". for searching the bugs.

First you test the "pp_blockgroupexp_jc10aro.lsp" isinside the "topograf_online--01.dwg"

If you have good results, then you try to execute in other Drawings.

๐Ÿคฃ

Please how to clone the Block (SprBlock  or ModelBlock)?

Already i use (command "copy" )..

(setq z80 "0.0,0.0,0.0") 
(command "_COPY" acblockRes "" z80 z80)
(command)
Question=How to use (vla-clone...)
   here, the new block must be in the same-position?

 

 

 

Command: q2
You select one(1)SprBlock inside.dwg:
Select objects: 1 found
Select objects:
You select all sprBlocks[Mybox]=
Select objects: Specify opposite corner: 6 found
Select objects:
Regenerating model.
Command:
Add-ToList[1-Add/2-Skip/0-Break]=1
Add-ToList[1-Add/2-Skip/0-Break]=1
Add-ToList[1-Add/2-Skip/0-Break]=1
Add-ToList[1-Add/2-Skip/0-Break]=1
Add-ToList[1-Add/2-Skip/0-Break]=1
Add-ToList[1-Add/2-Skip/0-Break]=1
(A0Arperezinf A1John.uhden A2Sea-Haven)
Destination Layer[A/1/2/0.exit]1_COPY
Select objects:   1 found
Set offsetDist(enter .-1.0)(inside<0)(outside>0)(0.exit)=30
_COPY
Set offsetDist(enter .30.0)(inside<0)(outside>0)(0.exit)=40

 

 

 

 

0 Likes
Message 14 of 28

arperezinf
Advocate
Advocate

Hello @john.uhden 

This is the information it gives me when I run the NOD command.

arpsolidworks-nod.gif

Thank you very much for reading my message.
Greetings.

0 Likes
Message 15 of 28

john.uhden
Mentor
Mentor

Drat.

It is a custom object that is not revealing the native AutoCAD objects that make it up.

I am afraid that leaves me stuck trying to help you out, even though it is a McBlock that probably has special sauce, lettuce, cheese, pickles, onions on a sesame seed bun.

John F. Uhden

0 Likes
Message 16 of 28

arperezinf
Advocate
Advocate

Hello @john.uhden @ronjonp 

 

If it's all a salad! But I'll find a way to do it.

 

Changing the subject. As I see that the routine of the friend @ronjonp will not work for me, with the code that I published at the beginning where I select the four points of the corners of the blocks of the streets, the yellow lines are created, then it asks me to enter the distance for offset the yellow lines, this part alone, even if I have to select the 4 corners until the offset, they can correct it for me to do the automatic offset.

(defun c:foo ()
      (setq pt1 (getpoint "\nFirst point:"))
     (setq pt2 (getpoint "\nSecond point:"))
     (setq pt3 (getpoint "\nThird point:"))
     (setq pt4 (getpoint "\nFourth point:"))
     (command "_pline" pt1 pt2 "")
     (command "_pline" pt2 pt3 "")
     (command "_pline" pt3 pt4 "")
     (command "_pline" pt4 pt1 "")
     (command "_offset")
     (princ)
)

Thank you very much for reading my message.
Greetings.

0 Likes
Message 17 of 28

arperezinf
Advocate
Advocate

Hola @john.uhden @ronjonp 

 

It could be that it lets me select all the vertices of the blocks of the streets, when I finish selecting the vertices, the yellow polylines are created, then it asks me for the distance and where I want to offset whether to inside or outside and to change the color of the polylines offset to the value 30.

Thank you very much for reading my message.
Greetings.

0 Likes
Message 18 of 28

arperezinf
Advocate
Advocate

Hello @john.uhden @ronjonp 

I say this to have at least one part solved to work, I know that the best way was as @ronjonp did but it does not work for me, maybe selecting the vertices of the blocks and streets will give me the lisp routine.

Thank you very much for reading my message.
Greetings.

0 Likes
Message 19 of 28

john.uhden
Mentor
Mentor
Just a thought...
He can probably make a copy and explode it (maybe twice like in C3D) to
expose the native contents which hopefully contain a polyline that he can
just offset. Then delete everything from the explosion(s).

John F. Uhden

0 Likes
Message 20 of 28

Sea-Haven
Mentor
Mentor

Can you post a dwg only need 1 big mac proxy object it may be exposed to us that have CIV3D/map it allows some access to custom objects. Will look into it with Bricscad also.

0 Likes