LISP hatch name in hyperlink

LISP hatch name in hyperlink

PSturmJ69HP
Participant Participant
689 Views
9 Replies
Message 1 of 10

LISP hatch name in hyperlink

PSturmJ69HP
Participant
Participant

Hi all,

 

For my work as engineer in the Netherlands i'm looking for a lisp routine that will use the hatch pattern name and place this name in the hyperlink. i don't no if this is possible. extra option would be selecting a hatch en genarate a hatch boundary on the hatch layer with the hatch pattern name in de boundary (polyline) hyperlink section.

 

I'm no expert in Lisp routines. When this routine works i will use it to mapexport the 2D drawing with hyperlink data to InfraWorks.

 

Could you please help me further with this?

 

Reference post:

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/select-hatchings-that-have-no-hyperl... 

0 Likes
Accepted solutions (1)
690 Views
9 Replies
Replies (9)
Message 2 of 10

ВeekeeCZ
Consultant
Consultant

 Not sure if follow... just give it a try.

 

(defun c:HatchHyperNoExtra ( / s i e p)
  
  (if (setq s (ssget '((0 . "HATCH"))))
    (repeat (setq i (sslength s))
      (setq e (ssname s (setq i (1- i))))
      (setq p (getpropertyvalue e "PatternName"))
      (command "_.-hyperlink" "_i" "_o" e "" p p "")))
  (princ)
  )
 

 

0 Likes
Message 3 of 10

PSturmJ69HP
Participant
Participant

Hello @ВeekeeCZ 

 

Thank you for responding. This is exactly what i was looking for. now this is working i want to test something extra.

With a solid hatch i would like to see the layer name in the hyperlink. is that possible?

 

When this is working i would like to generate close boundaries of multiple hatches. On the hatch layers end with the hyperlink data.

Hyperlink data (Solid hatch: layername, Patterned hatch: patternname).

 

Is it possible to make this in pne lisproutine? i would be very happy with this

 

0 Likes
Message 4 of 10

ВeekeeCZ
Consultant
Consultant

Perhaps something like this...

 

(vl-load-com)

(defun c:HatchHyperNoExtra ( / s i e p)
  
  (if (setq s (ssget '((0 . "HATCH"))))
    (repeat (setq i (sslength s))
      (setq e (ssname s (setq i (1- i))))
      (setq p (getpropertyvalue e "PatternName"))
      (if (= "SOLID" (strcat p))
	(setq p (cdr (assoc 8 (entget e)))))
      (command "_.-hyperlink" "_i" "_o" e "" p p "")))
  (princ)
  )

(defun c:HatchHyperBoudary ( / s i e l n)
  
  (if (setq s (ssget '((0 . "HATCH"))))
    (repeat (setq i (sslength s))
      (setq e (ssname s (setq i (1- i))))
      (vlax-for x (vlax-get-property (vlax-ename->vla-object e) 'Hyperlinks) (setq n (vlax-get-property x 'URL)))
      (if (and (setq l (entlast))
	       (or n (setq n "_NoHyperlink"))
	       (snvalid n 0)
	       (vl-cmdf "_.hatchgenerateboundary" e "")
	       )
	(while (setq l (entnext l))
	  (entmod (append (entget l) (list (cons 8 n))))))))
  (princ)
  )

 

0 Likes
Message 5 of 10

PSturmJ69HP
Participant
Participant

awesome @ВeekeeCZ! This very usefull.

 

For mapexport to InfraWorks. I now need to generate hatch boundaries on the hatch layers with the hyperlink information generated from this lisp routine.

 

is this also possible in this lisproutine?

 

as reference see the multiple hatch boundary. this works but now with hyperlink data created with your routine

0 Likes
Message 6 of 10

PSturmJ69HP
Participant
Participant

@ВeekeeCZ 

 

The hatches now have the right hyperlink information.

Is it possible to genarate closed boundaries with the hatch hyperlink?

When this last step works i'm done asking.

 

gr. Pim

0 Likes
Message 7 of 10

ВeekeeCZ
Consultant
Consultant

Ohh, would you? Promise?

 

I've posted some code a couple of days ago, that does not work? HatchHyperBoudary

"Is it possible to genarate closed boundaries with the hatch hyperlink?" - don't understand what this means.

0 Likes
Message 8 of 10

PSturmJ69HP
Participant
Participant

@ВeekeeCZ the result is not quite as i would like.

As attachemnt i send a dwg file as i would like to see the result.

the proces starts with hatches (solid or with patterns)

as final result i want closed polyline borders on the layers of the hatches with the filled in hyperlink data

 

hyperlink data:

solid hatch: layername

pattern hatch: patternname

 

result closed polylines on hatch layer with the hyperlink data of the hatch where the polyline is generated from.

 

The lisp you created are in the right way. but nog yet what i want. you're hyperlink data makes:

AVH-ASFALT-SO#AVH-ASFALT-SO

thats double filled in.

 

when the hyperlink is filled in right i want closed polylines. with the lisp they are not created.

 

maybe you can try it on the dwg i attached. Many thanks for helping me.

 

 

 

 

0 Likes
Message 9 of 10

ВeekeeCZ
Consultant
Consultant
Accepted solution

Ok, take it or leave it. No more edits from me.

 

(vl-load-com)

(defun c:HatchHyperNoExtra ( / s i e p)
  
  (if (setq s (ssget '((0 . "HATCH"))))
    (repeat (setq i (sslength s))
      (setq e (ssname s (setq i (1- i))))
      (setq p (getpropertyvalue e "PatternName"))
      (if (= "SOLID" (strcat p))
	(setq p (cdr (assoc 8 (entget e)))))
      (command "_.-hyperlink" "_i" "_o" e "" p "" "")))
  (princ)
  )


(defun c:BoundaryHyperple (/ *error* adoc clay ss i enl i ssl clay hyp) ; pgp B
  
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
      (princ (strcat "\nError: " errmsg)))
    (and (= (logand 8 (getvar 'undoctl)) 8) adoc (vla-endundomark adoc))
    (if clay (setvar 'clayer clay))
    (princ))
  
  (if (setq ss (ssget "_:L" '((0 . "HATCH"))))
    (progn
      (setq clay (getvar 'CLAYER))
      (setvar 'PEDITACCEPT 1)
      (vla-startundomark (setq adoc (vla-get-activedocument (vlax-get-acad-object))))
      
      (repeat (setq i (sslength ss))
	(setq ent (ssname ss (setq i (1- i)))
	      enl (entlast)
	      ssl (ssadd))
	(setvar 'CLAYER (setq lay (cdr (assoc 8 (entget ent)))))
	(command "_.-HATCHEDIT" ent "_b" "_p" "_y")
	(vlax-for x (vlax-get-property (vlax-ename->vla-object ent) 'Hyperlinks) (setq hyp (vlax-get-property x 'URL)))
	(while (setq enl (entnext enl))
	  (command "_.-hyperlink" "_i" "_o" enl "" (cond (hyp) ("")) "" "")
	  (ssadd enl ssl))
	(if (> (sslength ssl) 1)
	  (command "_.PEDIT" "_m" ssl "" "_j" "_j" "_b" "0.05" "")))
      (vla-endundomark adoc)
      ;(command "_erase" ss "")
      ;(vla-endundomark adoc)
      ;(princ "\n>> To restore hatches hit UNDO once.")
      ))
  (princ)
  )

 

Message 10 of 10

PSturmJ69HP
Participant
Participant

@ВeekeeCZ you're a legend! this lisp works like a dream. thank you for your time!

0 Likes