Hi all,
I have been searching something similar all over web but no luck.
I need lisp that would ask for point 1 (specified by user) , insert block1 (ie. light switch), than ask point 2, insert block2 (ie. pendant light), draw a line (or an arc) connecting two, ask for point3, insert block3 (ie. light switch, again), connects it with block 2 and so on...
Hope I was clear with idea and it is possible to make...
I should start working on electrical plans and since so many people before me had same problem with this i hope someone already have it.
Thanks and hoping for some help.
Cheers
Jan
I think the workflow is not as smooth as you described. There will be different lighting legends, curved route, breaks or arc at intersection, etc.
I am sure there is no easy solution , esspecialy if you wat to choose light symbols, but one of the workarounds would be to have all light symbols in one block with several visual states. In that case routine would deal with connecting blocks with lines and the morfing them into arcs. You would have to manually change - select state for each block, but still would be helpful. Also idea for connecting line- "cord" could be arc constructed from block insert points and end point of a new temporary line set as perpendicular of certan lenght from midpoint.( see sketch attached- easy to draw , hard to explain)
Is this too complicated?
Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.
@jahbgd wrote:
I am sure there is no easy solution , esspecialy if you wat to choose light symbols, but one of the workarounds would be to have all light symbols in one block with several visual states. In that case routine would deal with connecting blocks with lines and the morfing them into arcs. You would have to manually change - select state for each block, but still would be helpful. Also idea for connecting line- "cord" could be arc constructed from block insert points and end point of a new temporary line set as perpendicular of certan lenght from midpoint.( see sketch attached- easy to draw , hard to explain)
Is this too complicated?
Hi Jan,
I have an old code, and with some modifications, will do the arcs connecting the inserted blocks.
'perpendicular of certan lenght from midpoint'
The lenght will be always the same, or will have a relation (1/3 or 1/4) from the distance between blocks?
Henrique
Hi Scot,
Thanks for the answer. I was out of office for a few days.
In terms of arcs it is pretty close. The thing is that you need to have that middle click, but it is ok. I will be using it definutely.
Also, I realized that making the whole thing with inserting blocks etc too complicated, even in planning stage, not to mention programming.
Thanks!
Jan
Hi H,
As I said, I was out of office for a few days.
If you can share that code , maybe it will be useful.
Thanks!
Jan
@jahbgd wrote:
.... The thing is that you need to have that middle click, but .... Also, ... the whole thing with inserting blocks etc too complicated....
For already-inserted Blocks, here's a way to make continuous Arcs connecting them that doesn't require "that middle click," but only the picking on each Block in series. It doesn't use a constant bulge distance at the midpoint of each Arc as mentioned earlier [which would result in very different degrees of bulge at different lengths], but rather a constant starting-direction angle relative to the angle between the endpoints, for a consistent degree of bulge. I picked what looks to me like a reasonable degree of bulginess, but you can adjust that. It always bulges in the generally more upward direction.
Be aware that it's possible it will Snap to the insertion point of some nested entity within a given Block, if there are any such things, rather than to that of the Block itself, so if that's a possibility, be watchful while using it -- you can see what it's going to snap to before you pick. And it should, of course, be fleshed out to save the OSMODE value first and reset it later, etc., but see what you think:
(defun C:WA (/ pt1 pt2); = Wiring Arcs
(setvar 'osmode 64); Insertion
(setq pt1 (getpoint "\nStart point for Arc(s): "))
(while (setq pt2 (getpoint "\nEnd of Arc: "))
(command
"_.arc" pt1 "_e" pt2 "_direction" ; [spelling out "_end" is taken as Osnap call]
(angtos (apply (if (> (car pt2) (car pt1)) '+ '-) (list (angle pt1 pt2) (/ pi 5))))
; change 5 above to lower number for more bulge, higher for less
); command
(setq pt1 pt2); for start of next Arc
); while
); defun
Ahh, sorry I thought you will leave me to modify it (which i am not sure that i would manage) 🙂
I guess it will be better to have 1/4... I think i will be able to modify ratio to 1/3 ...
Thanks
Jan
Hi Kent,
Thanks for the effort. It works great and in the more timesaving manner. The catch with osnapmode is cool. At first i didnt realize that osnap works, because i want clicking near blocks 🙂 but than i realizet that "64" is INSertion.
Best
Jan
jahbgd wrote:I guess it will be better to have 1/4... I think i will be able to modify ratio to 1/3 ...
Jan,
you'll need to change the "H:\\your\\block\\library\\path\\" to the correct path...
(defun c:demo (/ *error* insrt -ang ang ang1 ang2 blk blk1 blk2 pt1 pt2 pt3 pt4) (defun *error* (msg) (cond ((not msg)) ((wcmatch (strcase msg) "*QUIT*,*CANCEL*")) (T (princ (strcat "\nError: " msg))) ) (princ) ) (defun insrt (/ ans blk flag) (setq flag t) (while flag (if (or blk (/= (setq blk (getvar 'INSNAME)) "") ) (progn (initget "Blockname") (setq ans (getpoint (strcat "\n Specify insertion point for '" blk "' or [Blockname] <exit>:") ) ) ) (setq ans "Blockname") ) (cond ((= 'list (type ans)) (command "-insert" blk ans) (while (> (getvar 'cmdactive) 0) (command "\\") ) (setq flag nil) (entlast) ) ((and ans (wcmatch ans "Blockname")) (if (not (setq blk (getfiled "Select a block" "H:\\your\\block\\library\\path\\" "dwg" 0 ) ) ) (setq flag nil) ) ) ((null ans) (princ "\n Exiting...") (setq flag nil) ) ) ) ) (setq blk (entlast)) (if (and (setq blk1 (insrt)) (not (eq blk blk1)) (setq pt1 (trans (cdr (assoc 10 (entget blk1))) 0 1)) (setq blk2 (insrt)) ) (while (and (not (null blk2)) (not (eq blk1 blk2)) ) (setq pt2 (trans (cdr (assoc 10 (entget blk2))) 0 1) pt3 (polar pt1 (angle pt1 pt2) (/ (distance pt1 pt2) 2.0)) ang (angle pt3 pt2) -ang (angle pt2 pt3) ) (grvecs (list -2 pt1 pt3 pt3 pt2)) (if (setq pt4 (getpoint pt3 "\n Pick arc side: ")) (progn (setq ang1 (angle pt3 pt4)) (if (< ang -ang) (if (<= ang ang1 -ang) (setq ang2 (/ (+ -ang ang) 2)) (setq ang2 (+ (/ (+ -ang ang) 2) pi)) ) (if (<= -ang ang1 ang) (setq ang2 (/ (+ -ang ang) 2)) (setq ang2 (+ (/ (+ -ang ang) 2) pi)) ) ) (command "_.redraw") (command "_.arc" "_NONE" pt1 "_NONE" (polar pt3 ang2 (/ (distance pt1 pt2) 3) "_NONE" pt2) (setq pt1 pt2 blk1 blk2 blk2 (insrt) ) ) (command "_.redraw") ) ) ) (*error* nil) (princ) )
Hope this helps,
Henrique
Jan,
I can no longer edit my previous post, so you'll need to add one ")" in
(command "_.arc" "_NONE" pt1 "_NONE" (polar pt3 ang2 (/ (distance pt1 pt2) 3)) "_NONE" pt2)
Henrique
Henrique,
Thanks for message and sorry for late answer.
I tried routine, but I find it a bit confusing.
It asks for a block(file) so there is a problem with basepoint, as it doesent use block basepoint but from file (i guess), and then there is connecting line problem, related to basepoint issue.
Sorry for the trouble, but if you decide to spend more time on this, i would suggest eliminating scale block part, maybe leave rotate, and in generating arcs, make fix ratio.I my personal opinion, it has too many option to select every time you use routine.
Anyhow thanks again for looking into this.
Cheers
Jan
@jahbgd wrote:
Henrique,
Thanks for message and sorry for late answer.
I tried routine, but I find it a bit confusing.
It asks for a block(file) so there is a problem with basepoint, as it doesent use block basepoint but from file (i guess), and then there is connecting line problem, related to basepoint issue.
Sorry for the trouble, but if you decide to spend more time on this, i would suggest eliminating scale block part, maybe leave rotate, and in generating arcs, make fix ratio.I my personal opinion, it has too many option to select every time you use routine.
You're welcome, Jan!
- 'I tried routine, but I find it a bit confusing.'
What is the command you use to insert the blocks?
Via tool Palettes?
Command 'insert'?
- Block insertion point...
How is your block library defined?
Each block is an independent file, or all the blocks are in one file?
_ 'i would suggest eliminating scale block part, maybe leave rotate, and in generating arcs, make fix ratio.I my personal opinion, it has too many option to select every time you use routine.'
Eliminate the scale, no problem.
The arcs have a fix ratio, the user have to pick one side for the arc...
Henrique
Hi, since I'm little sick.. I tried another method. You gonna need an extra line or polyline to show it's direction. Then you select BLOCKs or CIRCLEs and that polyline all together...
Hi,
This is a helpful command for me. However, when i use this command my snap settings are unchecked. Is there a way to keep my snaps checked when I use this command.
Thank you.
Regards,
Anesah
@adminJ7PFV wrote:
... when i use this command my snap settings are unchecked. Is there a way to keep my snaps checked when I use this command.
....
Remove this line:
(setvar 'osmode 64); Insertion
[which was part of the OP's process, to lock onto each Block's insertion point], and whatever your current Osnap settings are will remain.
@adminJ7PFV wrote:
.... when i use this command my snap settings are unchecked. Is there a way to keep my snaps checked when I use this command.
....
Come to think of it....
If by that you mean that you want your Osnap mode combination restored after running the routine, but you want it to use Insertion mode only during the routine [because you're wiring Blocks, like the OP], this will do that:
(defun C:WA (/ *error* osm pt1 pt2); = Wiring Arcs (defun *error* (errmsg) (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break")) (princ (strcat "\nError: " errmsg)) ); if (setvar 'osmode osm) ); defun - *error* (setq osm (getvar 'osmode)) (setvar 'osmode 64); Insertion (setq pt1 (getpoint "\nStart point for Arc(s): ")) (while (setq pt2 (getpoint "\nEnd of Arc: ")) (command "_.arc" pt1 "_e" pt2 "_direction" ; [spelling out "_end" is taken as Osnap call] (angtos (apply (if (> (car pt2) (car pt1)) '+ '-) (list (angle pt1 pt2) (/ pi 5)))) ; change 5 above to lower number for more bulge, higher for less ); command (setq pt1 pt2); for start of next Arc ); while (setvar 'osmode osm) ); defun
Or, if you want to add Insertion mode to your Osnap modes for snapping to Block insertion points, if it's not already among them, but still keep other modes that you have running, replace this line above:
(setvar 'osmode 64); Insertion
with this:
(setvar 'osmode (logior 64 (getvar 'osmode))); add Insertion if not already there