Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MLeader pickpoint and Z placement

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
JCprog
420 Views, 9 Replies

MLeader pickpoint and Z placement

Hello Everyone 🙂

 

I found this very useful code (below) at the swamp (credit to the guy who wrote it.....many thanks!). The routine will tag conduits by placing mleader which works perfect. The only problem is it always place the tag at 0 elevation. It would be nice if it sticks to the same elevation I picked. Please help. Thanks in advance 🙂

 

 

(defun c:cndtag ( / CNDEnt CNDObj PickPoint TagPoint CNDSize CNDSystem CNDTag)
(vl-load-com)
(setq 	CNDEnt (entsel "\nSelect the conduit to tag... ")
		CNDObj (vlax-ename->vla-object (car CNDEnt))
		PickPoint (cadr CNDEnt)
		TagPoint (getpoint PickPoint "\nPosition of conduit tag... ")
		)
(setq	CNDSize (substr (vlax-get-property CNDObj "SizeName") 1 4))
(cond 
	((= (substr CNDSize 2 3) ".00")(setq CNDSize (substr CNDSize 1 1)))
	((= (substr CNDSize 2 3) ".25")(setq CNDSize (strcat (substr CNDSize 1 1) " 1/4")))
	((= (substr CNDSize 2 3) ".50")(setq CNDSize (strcat (substr CNDSize 1 1) " 1/2")))
	((= (substr CNDSize 2 3) ".75")(setq CNDSize (strcat (substr CNDSize 1 1) " 3/4")))
)
(if	(= (substr CNDSize 1 2) "0 ")
	(setq CNDSize (vl-string-left-trim "0 " CNDSize))
)
(setq	CNDSystem (vlax-get-property CNDObj "Description")
		CNDTag (strcat CNDSize "\" C, " CNDSystem)
)
(command "_MLEADER" PickPoint TagPoint CNDTag)

 

9 REPLIES 9
Message 2 of 10
Shneuph
in reply to: JCprog

Is this possibly just a matter of setting "OSNAPZ" to 0?

---sig---------------------------------------
'(83 104 110 101 117 112 104 64 71 109 97 105 108 46 99 111 109)
Message 3 of 10
JCprog
in reply to: Shneuph

Hello Shneuph, thanks for ur reply. my osnapz is turned off and shouldnt matter or I dont want the osnapz to take any part on this routine. Basically I just need it to act like the OTB tags.
Message 4 of 10
hmsilva
in reply to: JCprog

Hi JCprog,

the returned point from 'entsel' function, is the crosshair location when you select the object, not a point from the object...

To get the point on the object you'll need to test the object points, to find the closer to the returned point, or using 'osnsp'

(setq ZPoint (osnap PickPoint "End"))

or

(setq ZPoint (osnap PickPoint "nea"))

or the necessary osnap

 

HTH

Henrique

EESignature

Message 5 of 10
JCprog
in reply to: hmsilva

Hello Henrique, I get this error somehow:
bad argument type: 2D/3D point: nil

I just need it to behave like a normal mleader.
Message 6 of 10
hmsilva
in reply to: JCprog

Maybe changing
(command "_MLEADER" PickPoint TagPoint CNDTag)
to
(command "_MLEADER" ZPoint TagPoint CNDTag)

Henrique

EESignature

Message 7 of 10
JCprog
in reply to: hmsilva

I got this:
Command: CNDTAG
Select the conduit to tag...
Position of conduit tag... Unknown command "1/2" C, ". Press F1 for help.
nil

Looks like it still looking for the "PickPoint"
Message 8 of 10
hmsilva
in reply to: JCprog


@JCprog wrote:
I got this:
Command: CNDTAG
Select the conduit to tag...
Position of conduit tag... Unknown command "1/2" C, ". Press F1 for help.
nil

Looks like it still looking for the "PickPoint"

Try

(defun c:cndtag	(/ CNDEnt CNDObj PickPoint TagPoint CNDSize CNDSystem CNDTag)
  (vl-load-com)
  (if
    (and (setq CNDEnt (entsel "\nSelect the conduit to tag... "))
	 (setq CNDObj (vlax-ename->vla-object (car CNDEnt)))
	 (setq PickPoint (osnap (cadr CNDEnt) "nea"))
	 (setq TagPoint (getpoint PickPoint "\nPosition of conduit tag... "))
	 (vlax-property-available-p CNDObj "SizeName")
	 (setq CNDSize (substr (vlax-get-property CNDObj "SizeName") 1 4))
	 (vlax-property-available-p CNDObj "Description")
	 (setq CNDSystem (vlax-get-property CNDObj "Description"))
    )
     (progn
       (cond
	 ((= (substr CNDSize 2 3) ".00") (setq CNDSize (substr CNDSize 1 1)))
	 ((= (substr CNDSize 2 3) ".25")
	  (setq CNDSize (strcat (substr CNDSize 1 1) " 1/4"))
	 )
	 ((= (substr CNDSize 2 3) ".50")
	  (setq CNDSize (strcat (substr CNDSize 1 1) " 1/2"))
	 )
	 ((= (substr CNDSize 2 3) ".75")
	  (setq CNDSize (strcat (substr CNDSize 1 1) " 3/4"))
	 )
       )
       (if (= (substr CNDSize 1 2) "0 ")
	 (setq CNDSize (vl-string-left-trim "0 " CNDSize))
       )
       (setq CNDTag (strcat CNDSize "\" C, " CNDSystem))
       (command "_MLEADER" PickPoint TagPoint CNDTag)
     )
  )
  (princ)
)

 

Untested...

 

Henrique

EESignature

Message 9 of 10
JCprog
in reply to: hmsilva

WOW!!!!! That worked awesome!!!!!Smiley Very Happy

 

Thanks Henrique!

Message 10 of 10
hmsilva
in reply to: JCprog

You're welcome, JCprog
Glad I could help

Henrique

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost