It is possible "get certain string from file name and change dimention scale " ?

It is possible "get certain string from file name and change dimention scale " ?

Anonymous
Not applicable
2,984 Views
23 Replies
Message 1 of 24

It is possible "get certain string from file name and change dimention scale " ?

Anonymous
Not applicable

hello everyone!

 

It is possible "get certain string from file name and change dimention scale " ?

 

To be specific.. if filename contains 1:100(1:200 or1:300...), it is the same as changing the scale of the dimensions 

 

i found like someting below...

 

 

 

 

 

- read filename

 

(defun C:pTxt()

     (setq fname(getstring "\n Enter a valid file name: "))

      (if(setq f(open fname "r"))

       (while (setq txtLine(read-line f))

        (princ txtLine)

       )        

       (princ "\n Error - Could not find file")

   )             

)       

 

 

 

 

- find certain string from list

 

(defun c:test(/ a yes)
(setq a (list "1" "2" "3"))
(setq yes (searchstring a "2"))
(if(= yes t)
(prompt "found")
(prompt "Not found")
)
)

 

 

 

 

 

- Change Dimension sclae

 

(defun c:Dimsc ( / *error* _StartUndo _EndUndo doc ss deflt old_b_scale alrim bp ojt )
(vl-load-com)
(defun *error* ( msg )
(and doc (_EndUndo doc))
(or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
(princ (strcat "\n** Error: " msg " **")))
(princ)
)

(defun _StartUndo ( doc ) (_EndUndo doc)
(vla-StartUndoMark doc)
)

(defun _EndUndo ( doc )
(if (= 8 (logand 8 (getvar 'UNDOCTL)))
(vla-EndUndoMark doc)
)
)


(setq fname(getstring "\n Enter a valid file name: "))

 

(setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))

(if (ssget "_X" '((0 . "*DIMENSION")))
(progn
(setq *scl* 1)
(setq *oscl*
(cond
(
(getdist
(strcat "\nSpecify Overall Scale Factor(Specify Overall Scale Factor) <"
(rtos
(setq *oscl* (cond ( *oscl* ) ( 1.0 )))
)
"> : "
)
)
)
( *oscl* )
)
)

(_StartUndo doc)

(vlax-for o (setq ss (vla-get-ActiveSelectionSet doc))
(mapcar
(function
(lambda ( prop value )
(if (vlax-property-available-p o prop)
(vlax-put-property o prop value)
)
)
)
'(LinearScaleFactor ScaleFactor) (list *scl* *oscl*)
)
)

(vla-delete ss)

(_EndUndo doc)
)
)
(princ)
)

 

 

 

 

 

Therefore, how can i mix these things to create what i want?

Please help me

 

thank you

0 Likes
Accepted solutions (1)
2,985 Views
23 Replies
Replies (23)
Message 21 of 24

Anonymous
Not applicable

Yes, it is clearly the character that is included in the filename.

 

It is just a (scale number) format like 'filename (scale 300) _ @'.

 

thanks.

0 Likes
Message 22 of 24

pbejse
Mentor
Mentor
Accepted solution

@Anonymous wrote:

Yes, it is clearly the character that is included in the filename.

 

It is just a (scale number) format like 'filename (scale 300)@ _ @'.

 

thanks.


This is the additional code:

 

(defun _validname&scale (str / p scl)
      (setq scl
      	(cond
              (	(setq p (vl-string-search "(SCALE" str))
               		(atoi (substr str (+ 8 p)))		)
              (	(and ( wcmatch str "*- 1-*#")
                     (setq p (vl-string-position 45 str nil t)))
                     	(read (substr str (+ 2 p)))		)
                 )
            )
 (if (numberp scl) scl)
                     )

It will accept both formats,  where filename is filename - 1-100.dwg or filename  (scale 300) _ @Anonymous

 

Attached is the modified code. Please let us know it the program works for you.

 

pBe

Message 23 of 24

Anonymous
Not applicable

It works well.
Thank you for your favor.

 

I will post the final code in this post after some modifications.
(With user guide video)

 

Once again, thanks to pbejse.

Bless you.

0 Likes
Message 24 of 24

pbejse
Mentor
Mentor

@Anonymous wrote:

It works well.
Thank you for your favor.

 

.....

Once again, thanks to pbejse.

Bless you.


Good for you kamilee2011

I may ask for a favor from you in the future with regards to BIM

....

You are welcome

 

Cheers

0 Likes