Author Topic: Lisp for connect between attribute definition values (Electrical Lisp)  (Read 4040 times)

0 Members and 1 Guest are viewing this topic.

jtm2020hyo

  • Newt
  • Posts: 198


TL;DR  I need to connect blocks using attribute values.

I created multiple blocks and attribute with different properties (Annotative, scaled attribute text to 1:50, Upside down, Backward, Invisible, Constant, Verify, Preset, Multiple lines, Lock position, Visibility parameters)



 





Request 1:
I need to request for help to create a lisp for connect with *lines between attribute definition values since their attribute insertion point or block insertion point, ignoring all properties, included caps, but Visibility parameters not should be ignored, all this just of selected blocks (dynamic blocks, regular blocks, nested blocks).

(check dwg attached for more details)

Request 2:
Add an option for let me choice if I need to ignore just specific attributes tag.

(in the attached drawing I ignored between attributes values “tipo” and “nivel”)

Request 2:
Add an option for let me choice if I need connect just specific attributes tag.

(in the attached drawing I connected between attributes values “codigo” and “alimentador”)

Request 3:
Add an option for let me choice for connect blocks insert point or attribute definitions insert point
(check dwg file and images for more details)




 

PD: attached blocks with the name “connect attributes.dwg”

PD: if possible use DCL or OpenDCL for the GUI.

BIGAL

  • Swamp Rat
  • Posts: 1410
  • 40 + years of using Autocad
Re: Lisp for connect between attribute definition values (Electrical Lisp)
« Reply #1 on: February 24, 2020, 11:06:04 PM »
Did you check your replies at the other forums ?
A man who never made a mistake never made anything

jtm2020hyo

  • Newt
  • Posts: 198
Re: Lisp for connect between attribute definition values (Electrical Lisp)
« Reply #2 on: February 25, 2020, 06:45:00 PM »
Did you check your replies at the other forums ?

still waiting for help in any forum

BIGAL

  • Swamp Rat
  • Posts: 1410
  • 40 + years of using Autocad
Re: Lisp for connect between attribute definition values (Electrical Lisp)
« Reply #3 on: February 25, 2020, 09:29:37 PM »
I asked some questions about how the lines should be drawn, did you answer ?
A man who never made a mistake never made anything

jtm2020hyo

  • Newt
  • Posts: 198
Re: Lisp for connect between attribute definition values (Electrical Lisp)
« Reply #4 on: February 25, 2020, 09:52:02 PM »
yep. I did.

... maybe , Do I did bad?


BIGAL

  • Swamp Rat
  • Posts: 1410
  • 40 + years of using Autocad
Yes that was my response about how are the lines  to be connected.

I think you have this posted on 3 Forums ? So it can be confusing which to follow.

I am BIGAL here and Cadtutor.
A man who never made a mistake never made anything

BIGAL

  • Swamp Rat
  • Posts: 1410
  • 40 + years of using Autocad
I had a play and it sort of works because there blocks and dynamic blocks it is making life difficult. Any way this is like version 1. You can mix and match atts and blocks.

Code: [Select]
; Join block or attribute by a line
; By Alan H March 2020


(defun c:Blkjoin ( / dyn lyr cnt strList tmp iStr gStr e ans)

(if (not AH:Butts)(load "Multi Radio buttons.lsp"))
(if (not but)(setq but 1))
(setq oldsnap (getvar 'osmode))
(setvar 'osmode 0)
(defun attpick ( / obj)
(setq obj (vlax-ename->vla-object (car (nentsel "\nPick Attribute "))))
(setq lst (cons (vlax-get Obj 'TextAlignmentPoint ) lst))
)

(defun blkpick ( / obj)
(setq obj (vlax-ename->vla-object (car (entsel "\nPick Block "))))
(setq lst (cons (vlax-get Obj 'InsertionPoint) lst))
)

(repeat 100
(setq lst '())
(if (= but 3)(setq but 1))
(ah:butts but "V"   '("Choose or exit  " "  Block" "  Attribute" "  Exit" ))
(cond
((= but 1)(blkpick))
((= but 2)(attpick))
((= but 3)(setvar 'osmode oldsnap)(exit))
)
(if (= but 3)(setq but 1))
(ah:butts but "V"   '("Choose or exit  " "  Block" "  Attribute" "  Exit" ))
(cond
((= but 1)(blkpick))
((= but 2)(attpick))
((= but 3)(setvar 'osmode oldsnap)(exit))
)

(command "line" (nth 0 lst)(nth 1 lst) "")
)

(princ)
)
(c:Blkjoin)

A man who never made a mistake never made anything

jtm2020hyo

  • Newt
  • Posts: 198
wow, an answer

thanks a lot for the lisp, I will test both and report for. just a request more, can you explain us what do both lisp routines? maybe both are complementaries?

BIGAL

  • Swamp Rat
  • Posts: 1410
  • 40 + years of using Autocad
Multi radio buttons.lsp is a library routine and you can use in any code, its writes a DCL file for input you can have 1 or as many radio buttons you need for stuff like "Yes or No" "A B C D E F G" you just save it to a location in your hard disk that is in your Autocad search path where you are saving all your other lisps. I have others getvals, toggles. It only needs 3 lines of code to be used in your code. There are examples in the code  they can be ran to see what happens.

The line code just use appload to load it or a menu etc it will auto load the Multi... code as required.
A man who never made a mistake never made anything

jtm2020hyo

  • Newt
  • Posts: 198
Re: Lisp for connect between attribute definition values (Electrical Lisp)
« Reply #10 on: March 16, 2020, 09:28:47 PM »
Multi radio buttons.lsp is a library routine and you can use in any code, its writes a DCL file for input you can have 1 or as many radio buttons you need for stuff like "Yes or No" "A B C D E F G" you just save it to a location in your hard disk that is in your Autocad search path where you are saving all your other lisps. I have others getvals, toggles. It only needs 3 lines of code to be used in your code. There are examples in the code  they can be ran to see what happens.

The line code just use appload to load it or a menu etc it will auto load the Multi... code as required.

awesome lisp sir. thanks a lot.








just a request more, is possible to connect automatically the attributes with same values with line but with the option to ignore some attributes for type or selected, and just in selected blocks?
« Last Edit: March 16, 2020, 09:33:10 PM by jtm2018hyo »

BIGAL

  • Swamp Rat
  • Posts: 1410
  • 40 + years of using Autocad
Re: Lisp for connect between attribute definition values (Electrical Lisp)
« Reply #11 on: March 17, 2020, 08:05:47 PM »
Not sure exactly sure what you want but drawing a line that matches a attribute value would be a bit random how would you know the connection order ?
A man who never made a mistake never made anything

jtm2020hyo

  • Newt
  • Posts: 198
Re: Lisp for connect between attribute definition values (Electrical Lisp)
« Reply #12 on: March 17, 2020, 11:20:53 PM »
Not sure exactly sure what you want but drawing a line that matches an attribute value would be a bit random how would you know the connection order?

the drawer that controls the attribute values with excel (attout), so if there are duplicates, then a warning message might appear, then accept (y)es or (n)o, if not then cancel action, if yes then all lines should be drawn, included the duplicated (like a spider web), why? for detecting that duplicates values and change values.

my idea is to work with codes,  because if codes can't be duplicated.

why connect attributes? if the line connect at the attributes middle center point, the using invisible attribute properties can be done to connect "conduit" or any pipe. I mean like the wire conduit properties in AUTOCAD MEP.