Trim command within autolisp selecting all dynamic block references

Trim command within autolisp selecting all dynamic block references

mikecomaroto
Participant Participant
1,239 Views
4 Replies
Message 1 of 5

Trim command within autolisp selecting all dynamic block references

mikecomaroto
Participant
Participant

The last couple lines of my code call the trim command on my newly inserted block (which is just a break line). The problem is that when I select objects to trim and there are more than one instance of this breakline dynamic block in the dwg file, the trim command thinks all of the blocks are participating and the user can trim lines around those blocks as well. I guess since they all have the same general name this is happening? I'm not a CAD expert, just  a structural engineer helping our team with some coding (it's fun!!!).

 

Code below; help is appreciated!!

 

(defun c:gfds-bl (/ e)

(setq fqp "K:\\Blocks\\GA-BREAK.dwg")

(vl-load-com)

(setq thisdrawing (vla-get-activedocument
(vlax-get-acad-object)))

(setq mspace (vla-get-modelspace thisdrawing))

(setq util (vla-get-utility thisdrawing))

(setq ip (getpoint "\nStart Point: ")
fp (getpoint ip "\nEnd Point:"))

(setq l (distance fp ip)) ;length of block

(setq a (angle ip fp)) ;anghle between points

(setq x 1.0
y 1.0
z 1.0
r a)

(setq lyr (getvar "clayer")) ;;gets current layer

(command "-layer" "set" "S-TEXT" "")

(setq theblock (vla-InsertBlock mspace (vlax-3d-point ip) fqp x y z r))

(setvar "clayer" lyr)

(setq prp (strcase "Length"))
(vl-some
'(lambda ( x )
(if (= prp (strcase (vla-get-propertyname x)))
(progn
(vla-put-value x (vlax-make-variant l (vlax-variant-type (vla-get-value x))))
(cond (l) (t))
)
)
)
(vlax-invoke theblock 'getdynamicblockproperties)
)

(setvar "CMDECHO" 0)

(setq e (ssget "L"))

(command "TRIM" e "")

(princ)

);defun

 

0 Likes
Accepted solutions (1)
1,240 Views
4 Replies
Replies (4)
Message 2 of 5

devitg
Advisor
Advisor

Please , upload this file GA-BREAK.dwg

0 Likes
Message 3 of 5

mikecomaroto
Participant
Participant

att

0 Likes
Message 4 of 5

Kent1Cooper
Consultant
Consultant

I have no idea, really, but just as a stab in the dark, try replacing:

(setq e (ssget "L"))

 

with

 

(setq e (entlast))

Kent Cooper, AIA
0 Likes
Message 5 of 5

mikecomaroto
Participant
Participant
Accepted solution

Thanks for the quick response!!!

 

My coworker solved this. The command routine should be issued as follows:

 

(command "trim" ip "")

 

Note since trim just needs a point to find an object, ip will suffice becuase it was where the user specified the insertion of the break line.

 

Hope this is usefull to someone else.

0 Likes