I need lisp opening drawing

I need lisp opening drawing

Anonymous
Not applicable
2,002 Views
12 Replies
Message 1 of 13

I need lisp opening drawing

Anonymous
Not applicable

Hi all, 

I need a lisp that can meet some requirements as below:

1, allow to select path to drawing folder

2, able to open drawing from text in an autocad file by right click or etc.....

3, "key" search is included, no need exactly

Exp drawing number is 1a-12345678, can search and open with key "1a-123456 or 123456"

 

Thank you all

0 Likes
2,003 Views
12 Replies
Replies (12)
Message 2 of 13

john.uhden
Mentor
Mentor

@Anonymous 

What do you mean by "able to open drawing from text in an autocad file by right click or etc.....?"

Do you mean to find a DWG containing a certain text string?

Or maybe you just mean to be able to type in part of drawing name, say with wildcards, then get a list of matching names to choose from.  I think the AutoCAD OPEN command can do that.

John F. Uhden

0 Likes
Message 3 of 13

pendean
Community Legend
Community Legend
HYPERLINK command is explained in HELP: explore it, it is what you seek.
0 Likes
Message 4 of 13

Anonymous
Not applicable

@john.uhden i mean

In Parts list of assembly drawing, we can see the text that include the part drawing number and i want to open that part drawing directly just by right click on the text and open it. Location to drawings folder is set in step 1.

@pendean hyperlink is not what i mean

0 Likes
Message 5 of 13

john.uhden
Mentor
Mentor

What kind of object is the parts list... text, mtext, table, block with attribute(s), OLE, thingamabob?

John F. Uhden

0 Likes
Message 6 of 13

Anonymous
Not applicable

@john.uhden 

i sent you an assembly drawing with parts list in it, 

look at to row 1, part number BLO-TENS-0000-0003 is also drawing number, i want to open this drawing directly

ngoc1357_0-1600391782746.png

 

 

https://drive.google.com/file/d/1XIp89lxAHfI6rdLSypEJTElCVFYTujoq/view?usp=sharing

 

Thank you

0 Likes
Message 7 of 13

Sea-Haven
Mentor
Mentor

It really does not matter wether a table, text, block etc need to just get the text value, if the library of parts is in support path directory then (command "open" "ABC123-456") will work.

 

A undocumented fact is support path can include multiple directories without naming them by using double ".." 

eg C:\myblocks\.. this will look lower down for block say ABC123-456.

 

So my recommendation is set support paths.

0 Likes
Message 8 of 13

jwhitleyWQHCV
Participant
Participant

I opened your test drawing and saw that the text is not an attribute but mtext in a block. This can make it difficult to select, separate from the block, to do a search. I do have a code that can help you a bit though. 

 

(defun ( / path name )

(setq name (getstring "ENTER FILE NAME" )) 

(setq path (findf name"C:\\")) ;; change path of C:\\ to narrow search path, doing so may speed things up otherwise it'll search your whole computer

(command "_.open" path)

)

 

(defun findf (fnm dir)
(setq dir (vl-string-right-trim
"\\"
(vl-string-translate "/" "\\" dir)
)
)
(cond
((findfile (strcat dir "\\" fnm)))
((vl-some '(lambda (xx) (findf fnm (strcat dir "\\" xx)))
(vl-remove "."
(vl-remove ".." (vl-directory-files dir nil -1))
)
)
)
)
)

0 Likes
Message 9 of 13

john.uhden
Mentor
Mentor

So sorry, Alan.

You know that I'm way behind the times (2002).  With my coronation I got a free copy of C3D2016, but my laptop is so old and weak that I have a very difficult time doing most anything in C3D.  Anyway, now I see what you mean.  Even if the data is in a table, you can pick on an entry using (nentsel), so I think that's the key.

Ya know if I don't get a job soon and be able to buy a newer computer to be able to run the newer versions I will have little value in these parts.

John F. Uhden

0 Likes
Message 10 of 13

Sea-Haven
Mentor
Mentor

Your right about nentsel

 

(setq txt (cdr (assoc 1 (entget (car (nentsel "\nSelect text"))))))
0 Likes
Message 11 of 13

Anonymous
Not applicable

Sorry all but i can not use any of your code, could please write a completed code for this issue. Thank

0 Likes
Message 12 of 13

john.uhden
Mentor
Mentor

@Anonymous 

You can use it if you learn.  That's what we are primarily here for... to help you learn, not to provide completed freeware because you are unwilling to learn to create your own.

Boy, do I hate repeating myself.

John F. Uhden

Message 13 of 13

devitg
Advisor
Advisor

@Anonymous  AKA 

vudungcom

 

You also  post it at CADTUTOR

 

https://www.cadtutor.net/forum/topic/71221-i-need-a-lisp-that-can-open-drawing-from-mtext-in-dwg/ 

 

 

 

 

 

 

 

 

0 Likes