Modify lisp to work only at certain angles and others...

Modify lisp to work only at certain angles and others...

jtm2020hyo
Collaborator Collaborator
3,284 Views
20 Replies
Message 1 of 21

Modify lisp to work only at certain angles and others...

jtm2020hyo
Collaborator
Collaborator

I have this lisp created for @dbhunia and work great. 

This lisp creates a line between one-block -in-whole-drawing to nearest blocks:

(defun C:BBL ( / )
(vl-load-com)
(setq SB_lst nil)
(setq NB_lst nil)
(princ "\nSelect a block(For Block Name) from which you want to draw line to Nearby Block (Other than Selected block)")
(Setq SB_Name (cdr (assoc 2 (entget(car(entsel)))))) 
(Setq selectionset (ssget "_A" '((0 . "INSERT"))))
(repeat (setq N (sslength selectionset))
	(setq Data (ssname selectionset (setq N (- N 1))))
	(setq EntityData (entget Data))
	(setq B_Name (cdr (assoc 2 EntityData)))
	(setq BP_Block (cdr (assoc 10 EntityData)))
	(if (= SB_Name B_Name)
		(setq SB_lst (cons BP_Block SB_lst))
		(setq NB_lst (cons BP_Block NB_lst))
	)
)
(repeat (setq N (length SB_lst))
	(setq BP_SB (nth (setq N (- N 1)) SB_lst))
	(setq DIS_lst nil)
	(repeat (setq N1 (length NB_lst))
		(setq BP_NB (nth (setq N1 (- N1 1)) NB_lst))
	    	(setq PD (distance BP_SB BP_NB))
		(setq DIS_lst (cons PD DIS_lst))
	)
(setq LDP (vl-position (apply 'min DIS_lst) DIS_lst))
(setq NP (nth LDP NB_lst))
(command "line" BP_SB NP "")
(princ)
)
)

 

...but I need more option:
1 just to work at certain angles. I need draw a pline between selected block and their nearest block but that is above base point (90 grades). Angle might be a variable.
2 just to work at the selected block of distinct names
3 link selected blocks to one block with a certain name or a layer with a certain name.

...I think those request will help a lot of people. 

image explain how I need request 1:
image.png

0 Likes
3,285 Views
20 Replies
Replies (20)
Message 2 of 21

dbhunia
Advisor
Advisor

Hi

 

As your requirement......

 


@jtm2020hyo wrote:

 

...................................

...but I need more option:
1 just to work at certain angles. I need draw a pline between selected block and their nearest block but that is above base point (90 grades). Angle might be a variable.
2 just to work at the selected block of distinct names
3 link selected blocks to one block with a certain name or a layer with a certain name.
...............................


 

Try this ......... (Blue one has been taken care.......)

 

 

(defun C:BBL (/);;Put Temp Variables here.....
(vl-load-com)
(setq SB_lst nil)
(setq NB_lst nil)
(Setq SB_Name (cdr (assoc 2 (entget(car(entsel "\nSelect a block(For Block Name) from which you want to draw line to Nearby Block (Other than Selected block)")))))) 
(Setq selectionset_SB (ssget "_A" (list '(0 . "INSERT") (cons 2 SB_Name))))
(initget 1 "Block Layer")
(setq NBO (getkword "\nSelect Nearest Objects by [Block Name/Layer Name]: "))
(if (= NBO "Block")
	(progn
		(princ "BLOCK")
		(Setq NSB (cdr (assoc 2 (entget(car(entsel "\nSelect a Nearby Block upto which you want to draw line...."))))))
		(Setq selectionset_NB (ssget "_A" (list '(0 . "INSERT") (cons 2 NSB))))
	)
	(progn
		(princ "LAYER")
		(Setq NSBL (cdr (assoc 8 (entget(car(entsel "\nSelect a Object for Layer which contain Nearby Block upto which you want to draw line...."))))))
		(Setq selectionset_NB (ssget "_A" (list '(0 . "INSERT") (cons 8 NSBL))))
	)
)
(repeat (setq N (sslength selectionset_SB))
	(setq BP_Block (cdr (assoc 10 (entget (ssname selectionset_SB (setq N (- N 1)))))))
	(setq SB_lst (cons BP_Block SB_lst))
)
(repeat (setq N (sslength selectionset_NB))
	(setq BP_Block (cdr (assoc 10 (entget (ssname selectionset_NB (setq N (- N 1)))))))
	(setq NB_lst (cons BP_Block NB_lst))
)
(repeat (setq N (length SB_lst))
	(setq BP_SB (nth (setq N (- N 1)) SB_lst))
	(setq DIS_lst nil)
	(repeat (setq N1 (length NB_lst))
		(setq BP_NB (nth (setq N1 (- N1 1)) NB_lst))
	    	(setq PD (distance BP_SB BP_NB))
		(setq DIS_lst (cons PD DIS_lst))
	)
(setq LDP (vl-position (apply 'min DIS_lst) DIS_lst))
(setq NP (nth LDP NB_lst))
(command "_.pline" BP_SB NP "")
(princ)
)
)

 

For Your 1st requirement (after looking the attached Image) I did not get your point.........

 

1   What do you mean by "certain angles" the "PLINE" angle .... connecting the base points of two Block.......?

What do you mean by  "90 grades" ........ difference of Y co-ordinate of two base points.......?

3  What about 180 degree in attached Image....?

 

 


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
Message 3 of 21

jtm2020hyo
Collaborator
Collaborator

@dbhunia wrote:

Hi

 

As your requirement......

 


@jtm2020hyo wrote:

 

...................................

...but I need more option:
1 just to work at certain angles. I need draw a pline between selected block and their nearest block but that is above base point (90 grades). Angle might be a variable.
2 just to work at the selected block of distinct names
3 link selected blocks to one block with a certain name or a layer with a certain name.
...............................


 

Try this ......... (Blue one has been taken care.......)

 

 

(defun C:BBL (/);;Put Temp Variables here.....
(vl-load-com)
(setq SB_lst nil)
(setq NB_lst nil)
(Setq SB_Name (cdr (assoc 2 (entget(car(entsel "\nSelect a block(For Block Name) from which you want to draw line to Nearby Block (Other than Selected block)")))))) 
(Setq selectionset_SB (ssget "_A" (list '(0 . "INSERT") (cons 2 SB_Name))))
(initget 1 "Block Layer")
(setq NBO (getkword "\nSelect Nearest Objects by [Block Name/Layer Name]: "))
(if (= NBO "Block")
	(progn
		(princ "BLOCK")
		(Setq NSB (cdr (assoc 2 (entget(car(entsel "\nSelect a Nearby Block upto which you want to draw line...."))))))
		(Setq selectionset_NB (ssget "_A" (list '(0 . "INSERT") (cons 2 NSB))))
	)
	(progn
		(princ "LAYER")
		(Setq NSBL (cdr (assoc 8 (entget(car(entsel "\nSelect a Object for Layer which contain Nearby Block upto which you want to draw line...."))))))
		(Setq selectionset_NB (ssget "_A" (list '(0 . "INSERT") (cons 8 NSBL))))
	)
)
(repeat (setq N (sslength selectionset_SB))
	(setq BP_Block (cdr (assoc 10 (entget (ssname selectionset_SB (setq N (- N 1)))))))
	(setq SB_lst (cons BP_Block SB_lst))
)
(repeat (setq N (sslength selectionset_NB))
	(setq BP_Block (cdr (assoc 10 (entget (ssname selectionset_NB (setq N (- N 1)))))))
	(setq NB_lst (cons BP_Block NB_lst))
)
(repeat (setq N (length SB_lst))
	(setq BP_SB (nth (setq N (- N 1)) SB_lst))
	(setq DIS_lst nil)
	(repeat (setq N1 (length NB_lst))
		(setq BP_NB (nth (setq N1 (- N1 1)) NB_lst))
	    	(setq PD (distance BP_SB BP_NB))
		(setq DIS_lst (cons PD DIS_lst))
	)
(setq LDP (vl-position (apply 'min DIS_lst) DIS_lst))
(setq NP (nth LDP NB_lst))
(command "_.pline" BP_SB NP "")
(princ)
)
)

 

For Your 1st requirement (after looking the attached Image) I did not get your point.........

 

1   What do you mean by "certain angles" the "PLINE" angle .... connecting the base points of two Block.......?

What do you mean by  "90 grades" ........ difference of Y co-ordinate of two base points.......?

3  What about 180 degree in attached Image....?

 

 ___________________

 

thanks for reply your code works great as always.

 

about the first request. I need to link to nearest blocks but ignoring (marked with red) blocks that are between 180 to 360 grades of the base point (should ignore their base point), no matter their rotation. (like the image)


image.png

0 Likes
Message 4 of 21

jtm2020hyo
Collaborator
Collaborator

hello @dbhunia
I was testing your code but I can't make it work
...I just received this : 



"BBL3

Select a block(For Block Name) from which you want to draw line to Nearby Block (Other than Selected block)
Select Nearest Objects by [Block Name/Layer Name]: L
LAYER
Select a Object for Layer which contain Nearby Block upto which you want to draw line....l-1"

 



 

 

AutoCAD menu utilities loaded.*Cancel*

Command:

Autodesk DWG.  This file is a TrustedDWG last saved by an Autodesk application or Autodesk licensed application.

Command:

Command:
Command:
Command:
Command: _pasteclip
Specify insertion point: *Cancel*

Command: *Cancel*

Command:
Command:
Command: _pasteclip
Command: (LOAD "C:/Users/JUAN-MINIPC/Google Drive/AUTOCAD-LISP-VBA-FAS/BLOCKs/LINK TO NEAREST BLOCK/SELECT BLOCK - LINK TO NAME OR LAYER/BBL3.LSP") C:BBL3

Command: BBL3

Select a block(For Block Name) from which you want to draw line to Nearby Block (Other than Selected block)
Select Nearest Objects by [Block Name/Layer Name]: B
BLOCK
Select a Nearby Block upto which you want to draw line....; error: bad argument type: lentityp nil

Command:
Command:
BBL3

Select a block(For Block Name) from which you want to draw line to Nearby Block (Other than Selected block)
Select Nearest Objects by [Block Name/Layer Name]: L
LAYER
Select a Object for Layer which contain Nearby Block upto which you want to draw line....l-1


*Invalid selection*
Expects a point or Last

Select a Object for Layer which contain Nearby Block upto which you want to draw line....l-1


*Invalid selection*
Expects a point or Last

Select a Object for Layer which contain Nearby Block upto which you want to draw line....; error: bad argument type: lselsetp nil

Command:
Command:
Command: *Cancel*



... Am I doing something bad?

 

0 Likes
Message 5 of 21

jtm2020hyo
Collaborator
Collaborator

I attached my test file. 

this lisp does not worh with red block in my drawing file.

0 Likes
Message 6 of 21

dbhunia
Advisor
Advisor

Hi,

 

Hi what I get from your post.......(if you are using my code (not modified), otherwise post the code)

 


@jtm2020hyo wrote:

hello @dbhunia
I was testing your code but I can't make it work
...I just received this : 



"BBL3

Select a block(For Block Name) from which you want to draw line to Nearby Block (Other than Selected block)
Select Nearest Objects by [Block Name/Layer Name]: L
LAYER
Select a Object for Layer which contain Nearby Block upto which you want to draw line....l-1"

 



 

 

AutoCAD menu utilities loaded.*Cancel*

Command:

Autodesk DWG.  This file is a TrustedDWG last saved by an Autodesk application or Autodesk licensed application.

Command:

Command:
Command:
Command:
Command: _pasteclip
Specify insertion point: *Cancel*

Command: *Cancel*

Command:
Command:
Command: _pasteclip
Command: (LOAD "C:/Users/JUAN-MINIPC/Google Drive/AUTOCAD-LISP-VBA-FAS/BLOCKs/LINK TO NEAREST BLOCK/SELECT BLOCK - LINK TO NAME OR LAYER/BBL3.LSP") C:BBL3

Command: BBL3

Select a block(For Block Name) from which you want to draw line to Nearby Block (Other than Selected block)
Select Nearest Objects by [Block Name/Layer Name]: B
BLOCK
Select a Nearby Block upto which you want to draw line....; error: bad argument type: lentityp nil

Command:
Command:
BBL3

Select a block(For Block Name) from which you want to draw line to Nearby Block (Other than Selected block)
Select Nearest Objects by [Block Name/Layer Name]: L
LAYER
Select a Object for Layer which contain Nearby Block upto which you want to draw line....l-1


*Invalid selection*
Expects a point or Last

Select a Object for Layer which contain Nearby Block upto which you want to draw line....l-1


*Invalid selection*
Expects a point or Last

Select a Object for Layer which contain Nearby Block upto which you want to draw line....; error: bad argument type: lselsetp nil

Command:
Command:
Command: *Cancel*



... Am I doing something bad?

 


 

Whenever code ask you......

 

"Select a Nearby Block upto which you want to draw line...." Or "Select a Object for Layer which contain Nearby Block upto which you want to draw line...." You have to either PICK a BLOCK or PICK any object from the LAYER using MOUSE no KEYBOARD entry (Red Marked).....


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
Message 7 of 21

jtm2020hyo
Collaborator
Collaborator

yes. I did that.

I was testing with more block and apparently, this lisp does not work with Dynamic Blocks.

This problem is related to all LISP that I was using. I found a lot of problems in google about Dynamic Blocks.

If you can fix this I will be grateful for ever.


@dbhunia wrote:

Hi,

 

Hi what I get from your post.......(if you are using my code (not modified), otherwise post the code)

 


@jtm2020hyo wrote:

hello @dbhunia
I was testing your code but I can't make it work
...I just received this : 



"BBL3

Select a block(For Block Name) from which you want to draw line to Nearby Block (Other than Selected block)
Select Nearest Objects by [Block Name/Layer Name]: L
LAYER
Select a Object for Layer which contain Nearby Block upto which you want to draw line....l-1"

 



 

 

AutoCAD menu utilities loaded.*Cancel*

Command:

Autodesk DWG.  This file is a TrustedDWG last saved by an Autodesk application or Autodesk licensed application.

Command:

Command:
Command:
Command:
Command: _pasteclip
Specify insertion point: *Cancel*

Command: *Cancel*

Command:
Command:
Command: _pasteclip
Command: (LOAD "C:/Users/JUAN-MINIPC/Google Drive/AUTOCAD-LISP-VBA-FAS/BLOCKs/LINK TO NEAREST BLOCK/SELECT BLOCK - LINK TO NAME OR LAYER/BBL3.LSP") C:BBL3

Command: BBL3

Select a block(For Block Name) from which you want to draw line to Nearby Block (Other than Selected block)
Select Nearest Objects by [Block Name/Layer Name]: B
BLOCK
Select a Nearby Block upto which you want to draw line....; error: bad argument type: lentityp nil

Command:
Command:
BBL3

Select a block(For Block Name) from which you want to draw line to Nearby Block (Other than Selected block)
Select Nearest Objects by [Block Name/Layer Name]: L
LAYER
Select a Object for Layer which contain Nearby Block upto which you want to draw line....l-1


*Invalid selection*
Expects a point or Last

Select a Object for Layer which contain Nearby Block upto which you want to draw line....l-1


*Invalid selection*
Expects a point or Last

Select a Object for Layer which contain Nearby Block upto which you want to draw line....; error: bad argument type: lselsetp nil

Command:
Command:
Command: *Cancel*



... Am I doing something bad?

 


 

Whenever code ask you......

 

"Select a Nearby Block upto which you want to draw line...." Or "Select a Object for Layer which contain Nearby Block upto which you want to draw line...." You have to either PICK a BLOCK or PICK any object from the LAYER using MOUSE no KEYBOARD entry (Red Marked).....


 

0 Likes
Message 8 of 21

dbhunia
Advisor
Advisor
Accepted solution

Hi

 

Try this.......

 

(defun C:BBL (/);;Put Temp Variables here.....
(vl-load-com)
(setq SB_lst nil)
(setq NB_lst nil)
(Setq SB_Name (cdr (assoc 2 (setq Data (entget(car(entsel "\nSelect a block(For Block Name) from which you want to draw line to Nearby Block (Other than Selected block)")))))))
(if (= (wcmatch SB_Name "*U*") T)
	(Setq SB_Name (vla-get-Effectivename (vlax-ename->vla-object (cdr (assoc -1 Data)))))
)
(Setq selectionset_SB (BLOCKSSET SB_Name))
(initget 1 "Block Layer")
(setq NBO (getkword "\nSelect Nearest Objects by [Block Name/Layer Name]: "))
(if (= NBO "Block")
	(progn
		(princ "BLOCK")
		(Setq NSB (cdr (assoc 2 (setq Data1 (entget(car(entsel "\nSelect a Nearby Block upto which you want to draw line....")))))))
		(if (= (wcmatch NSB "*U*") T)
			(Setq NSB (vla-get-Effectivename (vlax-ename->vla-object (cdr (assoc -1 Data1)))))
		)
		(Setq selectionset_NB (BLOCKSSET NSB))

		;(Setq selectionset_NB (ssget "_A" (list '(0 . "INSERT") (cons 2 NSB))))
	)
	(progn
		(princ "LAYER")
		(Setq NSBL (cdr (assoc 8 (entget(car(entsel "\nSelect a Object for Layer which contain Nearby Block upto which you want to draw line...."))))))
		(Setq selectionset_NB (ssget "_A" (list '(0 . "INSERT") (cons 8 NSBL))))
	)
)
(repeat (setq N (sslength selectionset_SB))
	(setq BP_Block (cdr (assoc 10 (entget (ssname selectionset_SB (setq N (- N 1)))))))
	(setq SB_lst (cons BP_Block SB_lst))
)
(repeat (setq N (sslength selectionset_NB))
	(setq BP_Block (cdr (assoc 10 (entget (ssname selectionset_NB (setq N (- N 1)))))))
	(setq NB_lst (cons BP_Block NB_lst))
)
(repeat (setq N (length SB_lst))
	(setq BP_SB (nth (setq N (- N 1)) SB_lst))
	(setq DIS_lst nil)
	(repeat (setq N1 (length NB_lst))
		(setq BP_NB (nth (setq N1 (- N1 1)) NB_lst))
	    	(setq PD (distance BP_SB BP_NB))
		(setq DIS_lst (cons PD DIS_lst))
	)
(setq LDP (vl-position (apply 'min DIS_lst) DIS_lst))
(setq NP (nth LDP NB_lst))
(command "_.pline" BP_SB NP "")
(princ)
)
)
(defun BlockSSET (blname / sset ss-dyn num ent effname)
   (vl-load-com) 
   (if (not (setq sset (ssget "X" (list (cons 2 blname)))))
      (setq sset (ssadd))
 )
 (if (setq ss-dyn (ssget "X" (list (cons 2 "`*U*"))))
      (progn
            (setq num 0)
           (repeat (sslength ss-dyn)
             (setq ent (ssname ss-dyn num))
             (setq effname (vla-get-EffectiveName (vlax-ename->vla-object ent)))
              (if (= blname effname)
                  (ssadd ent sset)
              )
         (setq num (1+ num))
            )
     )
 )
sset
)

Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
Message 9 of 21

jtm2020hyo
Collaborator
Collaborator

Thanks for fix code.

Its possible add a limiting option to allow code work just in a certain range of angles?

I want to use this code to link just with blocks that are between an angle range of 30 grades and 150 grades ( 120 grades like range vision for example) respect to block rotation.

0 Likes
Message 10 of 21

dbhunia
Advisor
Advisor
Accepted solution

Hi

 

The last code may be solved your problem........ But it will fail for the below reasons.......

 

If your selected block (non dynamic block) is named like "xxxxxUxxxx" or block name containing "U" .........

 

Then the below RED marked line become "T"......

For that reason code will go for BLUE marked line (to get the name of dynamic block)..... and the code will fail .....

 

 

(defun C:BBL (/);;Put Temp Variables here.....
....................
(Setq SB_Name (cdr (assoc 2 (setq Data (entget(car(entsel "\nSelect a block(For Block Name) from which you want to draw line to Nearby Block (Other than Selected block)")))))))
(if (= (wcmatch SB_Name "*U*") T)
	(Setq SB_Name (vla-get-Effectivename (vlax-ename->vla-object (cdr (assoc -1 Data)))))
)
(Setq selectionset_SB (BLOCKSSET SB_Name))
(initget 1 "Block Layer")
(setq NBO (getkword "\nSelect Nearest Objects by [Block Name/Layer Name]: "))
(if (= NBO "Block")
	(progn
		(princ "BLOCK")
		(Setq NSB (cdr (assoc 2 (setq Data1 (entget(car(entsel "\nSelect a Nearby Block upto which you want to draw line....")))))))
		(if (= (wcmatch NSB "*U*") T)
			(Setq NSB (vla-get-Effectivename (vlax-ename->vla-object (cdr (assoc -1 Data1)))))
		)
		(Setq selectionset_NB (BLOCKSSET NSB))
....................

 

 

So it is my suggestion to use the corrected code below......

 

(defun C:BBL (/);;Put Temp Variables here.....
(vl-load-com)
(setq SB_lst nil)
(setq NB_lst nil)
(Setq SB_Name (cdr (assoc 2 (setq Data (entget (setq PBP (car(entsel "\nSelect a block(For Block Name) from which you want to draw line to Nearby Block (Other than Selected block)"))))))))
(if (= :vlax-true (vla-get-IsDynamicBlock (vlax-ename->vla-object PBP)))
	(Setq SB_Name (vla-get-Effectivename (vlax-ename->vla-object (cdr (assoc -1 Data)))))
)
(Setq selectionset_SB (BLOCKSSET SB_Name))
(initget 1 "Block Layer")
(setq NBO (getkword "\nSelect Nearest Objects by [Block Name/Layer Name]: "))
(if (= NBO "Block")
	(progn
		(princ "BLOCK")
		(Setq NSB (cdr (assoc 2 (setq Data1 (entget (setq PBP1 (car(entsel "\nSelect a Nearby Block upto which you want to draw line...."))))))))
		(if (= :vlax-true (vla-get-IsDynamicBlock (vlax-ename->vla-object PBP1)))
			(Setq NSB (vla-get-Effectivename (vlax-ename->vla-object (cdr (assoc -1 Data1)))))
		)
		(Setq selectionset_NB (BLOCKSSET NSB))
	)
	(progn
		(princ "LAYER")
		(Setq NSBL (cdr (assoc 8 (entget(car(entsel "\nSelect a Object for Layer which contain Nearby Block upto which you want to draw line...."))))))
		(Setq selectionset_NB (ssget "_A" (list '(0 . "INSERT") (cons 8 NSBL))))
	)
)
(repeat (setq N (sslength selectionset_SB))
	(setq BP_Block (cdr (assoc 10 (entget (ssname selectionset_SB (setq N (- N 1)))))))
	(setq SB_lst (cons BP_Block SB_lst))
)
(repeat (setq N (sslength selectionset_NB))
	(setq BP_Block (cdr (assoc 10 (entget (ssname selectionset_NB (setq N (- N 1)))))))
	(setq NB_lst (cons BP_Block NB_lst))
)
(repeat (setq N (length SB_lst))
	(setq BP_SB (nth (setq N (- N 1)) SB_lst))
	(setq DIS_lst nil)
	(repeat (setq N1 (length NB_lst))
		(setq BP_NB (nth (setq N1 (- N1 1)) NB_lst))
	    	(setq PD (distance BP_SB BP_NB))
		(setq DIS_lst (cons PD DIS_lst))
	)
(setq LDP (vl-position (apply 'min DIS_lst) DIS_lst))
(setq NP (nth LDP NB_lst))
(command "_.pline" BP_SB NP "")
(princ)
)
)
(defun BlockSSET (blname / sset ss-dyn num ent effname)
(vl-load-com) 
  (if (not (setq sset (ssget "X" (list (cons 2 blname)))))
      (setq sset (ssadd))
  )
  (if (setq ss-dyn (ssget "X" (list (cons 2 "`*U*"))))
      (progn
           (setq num 0)
           (repeat (sslength ss-dyn)
             (setq ent (ssname ss-dyn num))
             (setq effname (vla-get-EffectiveName (vlax-ename->vla-object ent)))
              (if (= blname effname)
                  (ssadd ent sset)
              )
             (setq num (1+ num))
           )
      )
  )
sset
)

Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
Message 11 of 21

jtm2020hyo
Collaborator
Collaborator

Thanks for fix code again.

But returning to the original post, its possible add limiting options to allow code work just in a certain range of angles or ignore block between certain angles choice for the user?

I want to use this code to link just with blocks that are between an angle range of 0 grades (variable) and 180 grades ( variable) respect to block base point and their rotation, I need to ignore all block between 180 grades and 360 grades respect to block base point and their rotation. 

0 Likes
Message 12 of 21

dlanorh
Advisor
Advisor

Define 0 degrees, is it Autocad (East) along the x axis and anticlockwise  or Survey (North) along the y axis and clockwise?

I am not one of the robots you're looking for

0 Likes
Message 13 of 21

jtm2020hyo
Collaborator
Collaborator

@dlanorh wrote:

Define 0 degrees, is it Autocad (East) along the x axis and anticlockwise  or Survey (North) along the y axis and clockwise?


the concept is the same but instead axis I need to use block base point and should be considered in each block from where is create the polyline and angle should be an anticlockwise rotation.



0 Likes
Message 14 of 21

jtm2020hyo
Collaborator
Collaborator

something like this image (block marked with an "X" is ignored because are between 180 grades and 360 grades respect to basepoint angle 0)

image.png

0 Likes
Message 15 of 21

dlanorh
Advisor
Advisor

@jtm2020hyo wrote:


image.png


Is the 0-180 degrees relative to the rotation angle of the block you are drawing the line from? See attached drawing.

I am not one of the robots you're looking for

0 Likes
Message 16 of 21

dbhunia
Advisor
Advisor
Accepted solution

@jtm2020hyo wrote:

Thanks for fix code again.

But returning to the original post, its possible add limiting options to allow code work just in a certain range of angles or ignore block between certain angles choice for the user?

I want to use this code to link just with blocks that are between an angle range of 0 grades (variable) and 180 grades ( variable) respect to block base point and their rotation, I need to ignore all block between 180 grades and 360 grades respect to block base point and their rotation. 


 

Try this..........(It's lightly tested)

 

 


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
Message 17 of 21

jtm2020hyo
Collaborator
Collaborator

@dlanorh wrote:

@jtm2020hyo wrote:


image.png


Is the 0-180 degrees relative to the rotation angle of the block you are drawing the line from? See attached drawing.


Yes. In each block angle is relative

0 Likes
Message 18 of 21

dlanorh
Advisor
Advisor
Accepted solution

OK. Try the attached. It's not tested.

 

I am not one of the robots you're looking for

Message 19 of 21

dlanorh
Advisor
Advisor
Accepted solution

I managed to test and it didn't work for all "FROM" block rotations. I have amended and (minimally) tested, and the attached should now work.

 

I am not one of the robots you're looking for

Message 20 of 21

jtm2020hyo
Collaborator
Collaborator

@dlanorh wrote:

@jtm2020hyo wrote:


image.png


Is the 0-180 degrees relative to the rotation angle of the block you are drawing the line from? See attached drawing.





yes. your drawing attached explain better what I need.


image.png

0 Likes