hello
so I've been using this lisp by Kent1Cooper it works okay for me but I would like it to.
1. Select between two blocks depending on the layer of the pline it's being attached to.
2. I would also like it to align to the pline
Kent1Cooper's lisp:
(defun C:clp ; = Insert Block at Near End
(/ ss ent nogo)
(prompt "\nUsing only individual-pick or Fence selection option(s),")
(if (setq ss (ssget '((0 . "LINE,*POLYLINE,ARC")))) ;; include Spline/Ellipse if open? Ray?
(foreach item (ssnamex ss)
(if (member (car item) '(1 4)); individual-pick or Fence selection used
(progn ; then
(setq ent (cadr item)); entity name
(command "_.insert" "tie_options" "_scale" 1 "_none"
(if
(<
(vlax-curve-getDistAtPoint ent (vlax-curve-getClosestPointTo ent (last (last item))))
(/ (vlax-curve-getDistAtParam ent (vlax-curve-getEndParam ent)) 2); half length
); <
(vlax-curve-getStartPoint ent); then -- closer to start
(vlax-curve-getEndPoint ent); else
); if
(* ; rotation
(/
(angle
'(0 0 0)
(vlax-curve-getFirstDeriv ent (vlax-curve-getParamAtPoint ent (getvar 'lastpoint)))
); angle
pi
); /
180
); *
); command
); progn
(setq nogo T); else -- selected by wrong method
); if
); foreach
); if
(if nogo (prompt "\nSome object(s) selected by incorrect method(s)."))
(princ)
); defun
Solved! Go to Solution.
Solved by Kent1Cooper. Go to Solution.
1st suggestion, note not tested. If you have more layers change the IF to a cond so more can be added.
(setq ent (cadr item)); entity name
(setq lay (cdr (assoc 8 (entget item))))
(if (= lay "layer1")
(setq blkname "BLK1")
(setq blkname "tie_options")
)
(command "_.insert" blkname "_scale" 1 "_none"
2nd If the text angle is wrong you may need to add (/pi 2.0) to it
@omarvilla365 wrote:
.... I would like it to.
1. Select between two blocks depending on the layer of the pline it's being attached to.
2. I would also like it to align to the pline
....
1. I would make a list of sub-lists:
(setq LayBlkList '(("LayerA" "LayerABlock") ("LayerB" "LayerBBlock") ("LayerZ" "LayerZBlock")))
The choice of Block based on Layer can be done right inside the Insert command:
....
(command "_.insert"
(cadr (assoc (cdr (assoc 8 (entget ent))) LayBlkList))
"_scale" 1 "_none"
(if
....
It does require that the Blocks all be available. You can add as many sub-lists [Layer and Block name pairs] as you like.
2. Does it not align them for you? It does for me.
@ Kent1Cooper Thanks for replying I am super new at lisps where do i add these additions.
@omarvilla365 wrote:
.... where do i add these additions.
Ensure the appropriate Blocks are available and put their names into such a list with the
(setq LayBlkList ....
line [substituting your real Layer and Block names] above the
(prompt ....
line near the top. Replace the fixed Block name in the Insert command:
"tie_options"
with the function that will pull the one appropriate to the Layer:
(cadr (assoc (cdr (assoc 8 (entget ent))) LayBlkList))
Can't find what you're looking for? Ask the community or share your knowledge.