ccowgill
2010-01-08, 04:09 PM
Below is a program that I have written to work with one of our 3rd party softwares to allow us to use annotative blocks. It works great, but is slow. I'm sure my programming isnt the most efficient it could be. I understand that the program probably wont run, so any one that helps wont be able to test it, but maybe you can still assist me by helping me to see what I can do to make parts of the program run faster.
(defun c:setblock1
(/ annoscale blockent blockentdata blockset blockvla count)
(if (setq blockset
(ssget
"x"
'((0 . "INSERT")
(2
.
"ANT,DOT,BP,BUSH,CB,CI,CIRP,CO,CRB,DF,EMF,EMH,EMT,EO,ETR,FH,FNP,FOP,FP,GL,GM,GMF,GMP,GP,GUY,GV,HH,LP,MAJORTIC,MINORTIC,MB,MH,MW,OP,PH,PN,PP,RP,SAMH,SAT1,SB,SC,SCB,PLUS,SGN,SPG,SPH,ST,STMH,TMF,TMH,TP,TR,TRB,TSCB,VLT,WELL,WET,WLF,WM,WMH,WSO,WV,YDL,YP"
)
)
) ;_ end of ssget
) ;_ end of setq
(progn
(setq count 0
annoscale (vl-string-left-trim "1" (getvar "cannoscale"))
annoscale (atoi (vl-string-left-trim ":" annoscale))
) ;_ end of setq
(while (< count (sslength blockset))
(setq blockent (ssname blockset count)
blockentdata (entget blockent)
blockvla (vlax-ename->vla-object blockent)
) ;_ end of setq
(cond
((or (> (vla-get-xscalefactor blockvla) 1.0)
(> (vla-get-yscalefactor blockvla) 1.0)
(> (vla-get-zscalefactor blockvla) 1.0)
) ;_ end of or
(if
(wcmatch (cdr (assoc 2 blockentdata))
"MAJORTIC,MINORTIC"
) ;_ end of wcmatch
(progn
(vla-put-xscalefactor blockvla 1.0)
(vla-put-yscalefactor blockvla 1.0)
(vla-put-zscalefactor blockvla 1.0)
) ;_ end of progn
(progn
(vla-put-xscalefactor blockvla (/ 1.0 annoscale))
(vla-put-yscalefactor blockvla (/ 1.0 annoscale))
(vla-put-zscalefactor blockvla (/ 1.0 annoscale))
) ;_ end of progn
) ;_ end of if
) ;_ end of cond1
((or (< (vla-get-xscalefactor blockvla) 1.0)
(< (vla-get-yscalefactor blockvla) 1.0)
(< (vla-get-zscalefactor blockvla) 1.0)
) ;_ end of or
(vla-put-xscalefactor blockvla 1.0)
(vla-put-yscalefactor blockvla 1.0)
(vla-put-zscalefactor blockvla 1.0)
) ;_ end of cond2
) ;_ end of cond
(setq count (1+ count))
) ;_ end of while
(placeattrib blockset annoscale)
(vla-regen (vla-get-activedocument (vlax-get-acad-object))
acAllViewports
) ;_ end of vla-regen
) ;_ end of progn
) ;_ end of if
) ;_ end of defun
any help is appreciated.
(defun c:setblock1
(/ annoscale blockent blockentdata blockset blockvla count)
(if (setq blockset
(ssget
"x"
'((0 . "INSERT")
(2
.
"ANT,DOT,BP,BUSH,CB,CI,CIRP,CO,CRB,DF,EMF,EMH,EMT,EO,ETR,FH,FNP,FOP,FP,GL,GM,GMF,GMP,GP,GUY,GV,HH,LP,MAJORTIC,MINORTIC,MB,MH,MW,OP,PH,PN,PP,RP,SAMH,SAT1,SB,SC,SCB,PLUS,SGN,SPG,SPH,ST,STMH,TMF,TMH,TP,TR,TRB,TSCB,VLT,WELL,WET,WLF,WM,WMH,WSO,WV,YDL,YP"
)
)
) ;_ end of ssget
) ;_ end of setq
(progn
(setq count 0
annoscale (vl-string-left-trim "1" (getvar "cannoscale"))
annoscale (atoi (vl-string-left-trim ":" annoscale))
) ;_ end of setq
(while (< count (sslength blockset))
(setq blockent (ssname blockset count)
blockentdata (entget blockent)
blockvla (vlax-ename->vla-object blockent)
) ;_ end of setq
(cond
((or (> (vla-get-xscalefactor blockvla) 1.0)
(> (vla-get-yscalefactor blockvla) 1.0)
(> (vla-get-zscalefactor blockvla) 1.0)
) ;_ end of or
(if
(wcmatch (cdr (assoc 2 blockentdata))
"MAJORTIC,MINORTIC"
) ;_ end of wcmatch
(progn
(vla-put-xscalefactor blockvla 1.0)
(vla-put-yscalefactor blockvla 1.0)
(vla-put-zscalefactor blockvla 1.0)
) ;_ end of progn
(progn
(vla-put-xscalefactor blockvla (/ 1.0 annoscale))
(vla-put-yscalefactor blockvla (/ 1.0 annoscale))
(vla-put-zscalefactor blockvla (/ 1.0 annoscale))
) ;_ end of progn
) ;_ end of if
) ;_ end of cond1
((or (< (vla-get-xscalefactor blockvla) 1.0)
(< (vla-get-yscalefactor blockvla) 1.0)
(< (vla-get-zscalefactor blockvla) 1.0)
) ;_ end of or
(vla-put-xscalefactor blockvla 1.0)
(vla-put-yscalefactor blockvla 1.0)
(vla-put-zscalefactor blockvla 1.0)
) ;_ end of cond2
) ;_ end of cond
(setq count (1+ count))
) ;_ end of while
(placeattrib blockset annoscale)
(vla-regen (vla-get-activedocument (vlax-get-acad-object))
acAllViewports
) ;_ end of vla-regen
) ;_ end of progn
) ;_ end of if
) ;_ end of defun
any help is appreciated.