Selection set by window selection

Selection set by window selection

Anonymous
Not applicable
15,236 Views
92 Replies
Message 1 of 93

Selection set by window selection

Anonymous
Not applicable

I am trying to create a selection set by selecting entities by a window. i thought it was

 

(prompt "\nSelect Objects by Window")
(setq p1 (getpoint "\nFirst Corner: "))
(setq p2 (getpoint p1 "\nSecond Corner: "))
(setq ss1 (ssget "w" p1 p2))

 

i am having some trouble though. I must be missing something & just not thinking of it.

0 Likes
Accepted solutions (1)
15,237 Views
92 Replies
Replies (92)
Message 61 of 93

dlanorh
Advisor
Advisor

I don't know where you are geographically, so the link below is to an amazon.com page. Forget the books and look for the kindle or digital versions as they are a lot cheaper.

  https://www.amazon.com/Books-Reinaldo-N-Togores/s?rh=n%3A283155%2Cp_27%3AReinaldo+N.+Togores 

 

There are 4 or 5 books in the series. I know an update or such was published last year and there may be another in the pipeline for the new VS code interface.

 

I've also attached some pdf's you may find useful.

 

 

I am not one of the robots you're looking for

0 Likes
Message 62 of 93

Anonymous
Not applicable

Thanks so much. Yeah i'm on the east coast of the United States in Baltimore Maryland. i think i did see this before on amazon

0 Likes
Message 63 of 93

Anonymous
Not applicable

One last thing, I would like the pool.dwg to be in 2007 format. I found this in another post that has some code that does this. I would just change 48 to be 36

 

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/is-there-a-way-to-force-wblock-metho...

 

  (or *AcadObject* (setq *AcadObject* (vlax-get-acad-object)))
  (or *AcDoc*  (setq *AcDoc* (vla-get-ActiveDocument *AcadObject*)))
  (setenv "DefaultFormatForSave" "48") ; acad2010 format

If i add this here would that work or would i need to add something else?

 

 (cond (ss
(setq ass (vlax-get-property cdoc 'activeselectionset)
dfile (strcat (getvar 'dwgprefix) dnme ".dwg")
);end_setq

(or *AcadObject* (setq *AcadObject* (vlax-get-acad-object)))
(or *AcDoc* (setq *AcDoc* (vla-get-ActiveDocument *AcadObject*)))
(setenv "DefaultFormatForSave" "36") ; acad2007 format

(vlax-for itm ass (vlax-put itm 'color 7))
(vlax-invoke cdoc 'wblock dfile ass)
(setq dcnt (1+ dcnt) dnme (strcat dnme (itoa dcnt)))
)
(t (alert "Nothing Selected"))
)

0 Likes
Message 64 of 93

dlanorh
Advisor
Advisor

You need to get the current, change it, then reset on exit. See attached

I am not one of the robots you're looking for

0 Likes
Message 65 of 93

Anonymous
Not applicable

i'm not sure if this is saving it as a 2013 drawing or not. That is the correct format. version 2007=

(setenv "DefaultFormatForSave" "36")

When i open it it is saying its a 2013 drawing but when i run (setenv "DefaultFormatForSave" ) it returns 36.

 

Opening an AutoCAD 2013 format file.
Substituting [simplex.shx] for [IMPACT NoLines].
Regenerating model.
AutoCAD menu utilities loaded5
Command:
Autodesk DWG. This file is a TrustedDWG last saved by an Autodesk application or Autodesk licensed application.
Command:
Command:
Command: (getenv "DefaultFormatForSave")
"36"

0 Likes
Message 66 of 93

dlanorh
Advisor
Advisor

@Anonymous wrote:

i'm not sure if this is saving it as a 2013 drawing or not. That is the correct format. version 2007=

(setenv "DefaultFormatForSave" "36")

When i open it it is saying its a 2013 drawing but when i run (setenv "DefaultFormatForSave" ) it returns 36.

 

Opening an AutoCAD 2013 format file.
Substituting [simplex.shx] for [IMPACT NoLines].
Regenerating model.
AutoCAD menu utilities loaded5
Command:
Autodesk DWG. This file is a TrustedDWG last saved by an Autodesk application or Autodesk licensed application.
Command:
Command:
Command: (getenv "DefaultFormatForSave")
"36"


The only thing I can think of is that your system variable "FILEDIA" is set to 1. If it is try with it set to 0 (zero) as this should honour the (setenv). If it is already set to 0 then unfortunately I have no idea.

I am not one of the robots you're looking for

0 Likes
Message 67 of 93

Anonymous
Not applicable

Yeah its weird. It says its Opening an AutoCAD 2013 format file, but when i copy & paste (getenv "DefaultFormatForSave") into the command line it returns 36 which is Autocad 2007. When i open up the pool drawing then save as 2007 it updates it. "DefaultFormatForSave" still says 36.

0 Likes
Message 68 of 93

Anonymous
Not applicable

I was able to open up pool.dwg & run this code and it works. i'm not sure why its not doing it in WBpool.lsp

 

(defun c:version_update (/ filepath fe)
(setq filepath (strcat (getvar "dwgprefix")(getvar "dwgname")))
(setq fe (getenv "DefaultFormatForSave"))
(setenv "DefaultFormatForSave" "36")
)

 

Maybe i'm trying to do too much in one routine

0 Likes
Message 69 of 93

dlanorh
Advisor
Advisor

You may be able to do this using ODBX at the end of the WBPool lisp.

I am not one of the robots you're looking for

0 Likes
Message 70 of 93

Anonymous
Not applicable

I guess you mean object DBX? Something like this?

 

(setq ANOTHER-DOC (vla-getinterfaceobject (vlax-get-acad-object) (strcat "ObjectDBX.AxDbDocument." 2007))))

(vlax-dump-Object ANOTHER-DOC t) (vla-open ANOTHER-DOC FILE-NAME :vlax-false)

(vla-SaveAs another-doc filename)

 

On another post one of the members seems to suggest that file types are not supported with objectDBX

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-save-drawing-into-older-version-...

0 Likes
Message 71 of 93

dlanorh
Advisor
Advisor

if you read the last reply he suggests it would be possible to do this using accoreconsole. I have never used this, so my input here wouldn't be useful. I don't know if it can be run while AutoCAD is active. I think it requires running a small script in a batch processor, where all drawings are opened processed and closed in the background.

 

Lee Mac has a Script writer HERE Reading his page will certainly help, and it contains a link to a tutorial on writing scripts. Otherwise there are others here, at CADTutor (they have a scripts and macros Forum) and maybe TheSwamp (no dedicated Forum use the search facility and scripts); who would be better placed to help you, as I know nothing about writing scripts. ☹️

I am not one of the robots you're looking for

0 Likes
Message 72 of 93

Anonymous
Not applicable

Yes this is turning out to be quite complicated. It is a chance to learn though. Yes, i was asking over at the swamp how to do this. Apparently that code i had you add in just sets up the next drawing to be version 2007. It doesn't save the pool.dwg to the 2007 format.

0 Likes
Message 73 of 93

dlanorh
Advisor
Advisor

Coming at this from a different direction, what happens if you save the drawing (using the saveas method) as say dwgname +"_2007" at the start of WBPool.lsp. Does this then save the wblocks in 2007 format? You could even save the drawing then saveas the reload the original. Complicated but if it works everything is in the one lisp.

I am not one of the robots you're looking for

0 Likes
Message 74 of 93

Anonymous
Not applicable

so you're saying save 20-0135 ALL REV 7-15.dwg (the original drawing template) as 2007 & then wblock the entities out (hopefully in 2007 format) & then save the original back to 2013 version or whatever it is?

0 Likes
Message 75 of 93

cadffm
Consultant
Consultant

I can not see where you saving your current file, sorry if i miss the problem

 

(defun c:SAVEAS2007 (/ fe) ; but you should use an *error* handler, because default saveas 2007

is not a good idea as usual setting.



(setq fe (getenv "DefaultFormatForSave"))
(setenv "DefaultFormatForSave" "36")
(command "_.QSAVE")
(setenv "DefaultFormatForSave" fe)

)

 

 

Command: SAVEAS2007

 

or (c:SAVEAS2007)

but you can also use (command "_.SAVEAS" "2007" "" "_yes)


(command "_.SAVEAS" "2013" "" "_yes")

Sebastian

0 Likes
Message 76 of 93

Anonymous
Not applicable

The current file which would be the template file, which in this case is (20-0135 ALL REV 7-15.dwg). It will be whatever returns from (vla-get-activedocument (vlax-get-acad-object)) which will be the variable  cdoc . This is the same file that is open when the wblock selection set is run.

0 Likes
Message 77 of 93

cadffm
Consultant
Consultant

Sorry,

my sample was about QSAVE, but it is the same for WBLOCK

what i mean is:

Using activeX this way is not using the default format setting.

 

I am pretty sure all works fine with the (command version,

the thread started without activex, why was this change?

 

Use ssget and (command "_.-WBLOCK

It works.. You just need a function for checking about existing pool.dwg files

 

Cannot believe why this thread is not solved

 

Sebastian

0 Likes
Message 78 of 93

Anonymous
Not applicable

That's probably my fault. I kept adding things is most likely the reason that this isn't solved yet. This routine has evolved from the start because i was trying to do a lot of different things with this one routine and lots of different programmers are trying to help me.

0 Likes
Message 79 of 93

dlanorh
Advisor
Advisor

If you have entities in it is it still a template drawing? If so you would want to save it Yes?

 

So what a meant was :

 

1. save drawing (full save).

 

2. Save as 2007 format (vlax-invoke cdoc 'saveas "2007 filename" ac2007_dwg)

where ac2007_dwg is an internal constant. It should be in your AutoCAD version if it is 2013-2015

 

3. run WBPool

 

4. load normal dwg.

 

So, if you save the drawing in 2007 format before running WBPool does the wblock write the file in 2007 format? If it does then we're OK if it doesn't you have to go with the accoreconsole solution.

 

I've got to go to the animal hospital to pick up a pet after an operation so won't be around for the rest of the evening.

 

I am not one of the robots you're looking for

0 Likes
Message 80 of 93

cadffm
Consultant
Consultant

@dlanorh 

It should also not working for you (just if you working with AutoCAD 2007/8/9

ActiveX (your vlax-invoke WBLOCK part) is not using the default file format and has nothing to do with the format

of  the current file.

 

Is that something different with you?

Sebastian

0 Likes