Hatch with handle selection from attribute value

Hatch with handle selection from attribute value

djurk_haas
Advocate Advocate
768 Views
1 Reply
Message 1 of 2

Hatch with handle selection from attribute value

djurk_haas
Advocate
Advocate

Hello,

 

The code "Excel-total" has been added to the attachment and it works fine. However, I have to generate this code in Excel (due to the selection of handle's to be hatched).

Based on a code that "pbejse" previously made for me (thanks again), I think it is possible to avoid the necessary trip to Excel.
The code in "AfdelingID" is the modified code but my knowledge is much too little to get it working.

The code need to do the folowing:

the value in the attribute tag "VLRHANDLE_AUTOCAD" (handle of a polyline) is intended to have solid shading and the color depends on the value in "VLEKKENPLAN_AFDELING";
if the value is "OK" then the solid hatch must have color 1 and if the value is "SEH" then the solid hatch must have color 2.
Subsequently, these solid hatches must be placed on the layer "A--A$1-afdeling 0001".

0 Likes
Accepted solutions (1)
769 Views
1 Reply
Reply (1)
Message 2 of 2

pbejse
Mentor
Mentor
Accepted solution

@djurk_haas wrote:

The code "Excel-total" has been added to the attachment and it works fine.... I think it is possible to avoid the necessary trip to Excel.

 Hi, I dont see a connection to Excel on the posted Excel-Total.lsp file. Did you took that part off the code?

 


@djurk_haas wrote:

The code in "AfdelingID" is the modified code but my knowledge is much too little to get it working.

...


I am not sure how you fill the value for "VLRHANDLE_AUTOCAD" on your existing blocks, but nowhere on your sample drawing the values found on any block matches the Handle on any any "LWPOLYLINE" entity on your drawing.

 

The code below will only work if there's a matching handle found

 

 

(defun c:Afdeling_ID
       (/  ss i ev vatb handle afdeling HColor)
  (if (and
	(tblsearch "BLOCK" "FM_RM3")
	(setq ss (ssget "_X" '((0 . "insert") (66 . 1) (2 . "`*U*,FM_RM3"))))
      )
    (repeat (setq i (sslength ss))
      (setq ev (vlax-ename->vla-object (ssname ss (setq i (1- i)))))
      (if
	(and
	  (eq (strcase (vla-get-effectivename ev)) "FM_RM3")
	  (setq	vatb (mapcar '(lambda (at)
				(list (vla-get-tagstring at)
				      (vla-get-textstring at)
				)
			      )
			     (vlax-invoke ev 'Getattributes)
		     )
	  )
	  (setq handle (handent (cadr (assoc "VLRHANDLE_AUTOCAD" vatb)))
	  )
	  (Setq afdeling (cadr (assoc "VLEKKENPLAN_AFDELING" vatb)))
	)
	 (progn
	   (if
	     (setq HColor (cadr (Assoc afdeling '(("OK" 1) ("SEH" 2)))))
	      (command "hatch"	   "solid"     handle	   ""
		       "change"	   "LAST"      ""	   "P"
		       "LA"	   "A--A$1-afdeling 0001"  "C"
		       HColor	   ""	       "draworder" "LAST"
		       ""	   "BACK"
		      )
	      (prompt "Afdeling onbekend")
	   )
	 )
      )
    )
  )
  (princ)
)

 

 

 HTH

 

BTW: You never get back to us on your previous request Combine code to make it even better .

Never really understand why forum members just leave others hanging like that. 

 

R E S P E C T --> Find out what it means to me