Author Topic: getpoint and entsel combo pick?  (Read 2882 times)

0 Members and 1 Guest are viewing this topic.

phoulx

  • Guest
getpoint and entsel combo pick?
« on: September 19, 2006, 10:26:50 AM »
Mild dabbler in lisp speaking here.  I'm trying to figure out a way to have the user make one pick which would both set the current layer to match that object (a line) and use that pick as the getpoint location.  Originally, I had one pick for the getpoint and one for entsel but it seems to make sense to combine it somehow.  Any hints, gentle nudging, etc would be appreciated. 

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: getpoint and entsel combo pick?
« Reply #1 on: September 19, 2006, 10:32:12 AM »
Gentle nudge: getpoint and nentselp.

:)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: getpoint and entsel combo pick?
« Reply #2 on: September 19, 2006, 10:47:24 AM »
if (entsel) returns the entity & the pick point you almost have both.
I say almost as the pick point my not be exactly on the object.
To get the point on the object use vlax-curve-getclosestpointto

Code: [Select]
(defun c:test ()
  (and
    (setq entg (entsel "\nSelect the point on the entity."))
    (setq pt (vlax-curve-getclosestpointto (car entg) (cadr entg)))
    (setq ent (car entg))
  )
  (princ)
)

P.S.
Oh, if you want Osnaps to play a role in the point selection then you will need to do it as Michael suggested.
« Last Edit: September 19, 2006, 10:54:02 AM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

phoulx

  • Guest
Re: getpoint and entsel combo pick?
« Reply #3 on: September 21, 2006, 10:37:55 AM »
OK, the nentselp threw me for a while (matrix?!? what matrix) but I got this to work and it's exactly what I want.  Thanks for the clue!  BTW, this will cope a structural beam, W or HSS.  The user picks are to nearest (not exact distances) so the cope location can just be "eyeballed" to where the user wants it.  The layer gets set to match the picked structural element, a filleted pline creates the cope and then the user picks the lines to be trimmed.
Code: [Select]
(defun c:cop (/ OMD OSM FRAD CLAY PTC PTL PTD DISTL DISTD ANGL ANGD PTI COPLAY)
(setvar "cmdecho" 1)
(setq OMD (getvar "orthomode")) ;;gets current orthomode
(setvar "orthomode" 0) ;;sets orthomode to 0
(setq OSM (getvar "osmode")) ;;gets current osnap mode
(setvar "osmode" 32) ;;sets osnap mode to intersection
(setq FRAD (getvar "filletrad")) ;;gets current fillet radius
(setq CLAY (getvar "clayer")) ;;gets current layer

(setq PTC (getpoint "\nPick the structural shape corner <intersection>: "))
 (setvar "osmode" 512) ;;sets osnap mode to nearest

(setq PTL (getpoint "\nSelect lengthwise edge <nearest>: ")
e (car (nentselp PTL)))
 (setq PTD (getpoint "\nSelect depthwise edge <nearest>: "))
  (setq DISTL (distance PTC PTL))
  (setq DISTD (distance PTC PTD))
  (setq ANGL (angle PTC PTL))
  (setq ANGD (angle PTC PTD))
  (setq PTI (polar PTL ANGD DISTD))

(setq COPLAY (cdr (assoc 8 (entget (car (nentselp PTL))))))
(command "-layer" "s" COPLAY "")

(command "pline" PTL "w" "0" "0" PTI PTD "")
(command "fillet" "r" "0.5")
(command "fillet" "p" "L")
(setvar "cmdecho" 1)
(command "trim" "L" "" pause)

(setvar "clayer" CLAY) ;;resets to original layer
(setvar "filletrad" FRAD) ;;resets to original fillet radius
(setvar "osmode" OSM) ;;resets to original osnap mode
(setvar "orthomode" OMD) ;;resets to original orthomode
(princ)
)