🙏🏿 How to redraw the block of a neighborhood when selecting

🙏🏿 How to redraw the block of a neighborhood when selecting

arperezinf
Advocate Advocate
2,167 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,168 Views
27 Replies
Replies (27)
Message 21 of 28

diagodose2009
Collaborator
Collaborator

I need only duplicate the blockObject, before executing the command vla-explode.

Please , you  duplicate with (vla-clone or (vla-copy.,

0 Likes
Message 22 of 28

john.uhden
Mentor
Mentor
vla-copy should do just fine, if
(vlax-method-applicable-p object 'Copy)
returns T

John F. Uhden

0 Likes
Message 23 of 28

calderg1000
Mentor
Mentor

Regards @arperezinf 

In the meantime, here is this code complementing your idea of ​​selecting points. You must have previously created the required layers.

 

(vl-load-com)
(defun tt ()
  (setq
    spm (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))
  )

  (setq pt1 (getpoint "\nFirst point:")
        pt2 (getpoint "\nSecond point:")
        pt3 (getpoint "\nThird point:")
        pt4 (getpoint "\nFourth point:")
  )
  (vla-offset (setq l1 (vla-addline spm (vlax-3d-point pt1) (vlax-3d-point pt2)))
              d
  )
  (Setq s1 (entlast))
  (vla-put-layer l1 "L1RF")
  (vla-put-layer (vlax-ename->vla-object s1) "L2AI")

  (vla-offset (setq l2 (vla-addline spm (vlax-3d-point pt2) (vlax-3d-point pt3)))
              d
  )
  (Setq s2 (entlast))
  (vla-put-layer l2 "L1RF")
  (vla-put-layer (vlax-ename->vla-object s2) "L2AI")

  (vla-offset (setq l3 (vla-addline spm (vlax-3d-point pt3) (vlax-3d-point pt4)))
              d
  )
  (Setq s3 (entlast))
  (vla-put-layer l3 "L1RF")
  (vla-put-layer (vlax-ename->vla-object s3) "L2AI")

  (vla-offset (setq l4 (vla-addline spm (vlax-3d-point pt4) (vlax-3d-point pt1)))
              d
  )
  (Setq s4 (entlast))
  (vla-put-layer l4 "L1RF")
  (vla-put-layer (vlax-ename->vla-object s4) "L2AI")
)

(defun c:foo (/ spm I O d pt1 pt2 pt3 pt4 l1 l2 l3 l4 s1 s2 s3 s4)
  (setq d (getreal "\n Enter Offset distance:"))
  (initget "I O")
  (setq opc (getkword "\nInside/Outside [I/O] <I>:"))
  (if (= opc "I")
    (progn
      (setq d (- d))
      (tt)
    )
  )
  (if (= opc "O")
    (progn
      (setq d d)
      (tt)
    )
  )
)

 

 


Carlos Calderon G
EESignature
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

0 Likes
Message 24 of 28

arperezinf
Advocate
Advocate

Hello @john.uhden @ronjonp @Sea-Haven 

Sorry for the delay in responding on this topic, but I've been researching why your lisp routines don't work for me and I can't find the solution.

I have used this code, I create the lines by clicking on 4 points, then I do the offset of the lines, finally I do this manually, I select the offset polylines I change them from the "L1RF" layer to the "L2AI" layer and then I use the explode command.

I don't know how to make this last part work automatically for me and I don't have to do it manually.

 

This is the code I am using:

 

(defun c:foo ()
(while (= (logand (getvar "cmdactive") 0) 0) 
       (setq pt1 (getpoint "\nFirst point:"))
       (setq pt2 (getpoint "\nSecond point:"))
       (setq pt3 (getpoint "\nThird point:"))
       (setq pt4 (getpoint "\nFourth point:"))
       (command "_pline" pt1 pt2 pt3 pt4 pt1 "")
       (while (= (logand (getvar "cmdactive") 1) 1) 
         (command pause)
       )
       (command "_offset")
       (while (= (logand (getvar "cmdactive") 1) 1) 
         (command pause)
       )
       (princ)
     )
)

 

 Thank you very much for reading my message and again sorry for the delay in responding.
Greetings.

0 Likes
Message 25 of 28

john.uhden
Mentor
Mentor

@arperezinf 

Your code worked for me, but it could be improved.  For instance, rather than repeating pt1 to close the polyline, just "_Close" it.  Also, it would be handy to see where the previous points were.  So...

(and
  (setq pt1 (getpoint "\nFirst point:"))
  (setq pt2 (getpoint pt1 "\nSecond point:"))
  (setq pt3 (getpoint pt2 "\nThird point:"))
  (setq pt4 (getpoint pt3 "\nFourth point:"))
  (vl-cmdf "_.pline" pt1 pt2 pt3 pt4 "_C")
  (vl-cmdf "_.offset")
  (while (= (logand (getvar "cmdactive") 1) 1) (vl-cmdf pause) )
  (princ)
)

John F. Uhden

Message 26 of 28

arperezinf
Advocate
Advocate

Hello @john.uhden 👋

how long without talking 😀
It works for me too your modification thank you.

 

I don't understand what you mean by this.

"Also, it would be handy to see where the previous points were. So..."

 

Thank you very much for reading my message.
Greetings.

 

0 Likes
Message 27 of 28

john.uhden
Mentor
Mentor

@arperezinf 

By "previous points" I mean getting the rubber band showing from point to next point.

BTW, I know I have the code to make it simpler, but no time to put it together for you.

John F. Uhden

0 Likes
Message 28 of 28

arperezinf
Advocate
Advocate

Hello @john.uhden 
Now I understand.
No problem.
I'm working with what I have and by the way I'm still investigating.

Thank you very much for reading my message.
Greetings.

0 Likes