Hi there,
I am wondering if it is possible to use AutoCAD command to finish below task, (to input AutoCAD command in command line, in order to create script later)
change all Vport to layer $X-ANNO-VPRT,
color by layer,
Bring Vport to Front (in draw order)
Thank you very much in advance! 🙂
Solved! Go to Solution.
Solved by paullimapa. Go to Solution.
Solved by paullimapa. Go to Solution.
Solved by paullimapa. Go to Solution.
Solved by paullimapa. Go to Solution.
Solved by paullimapa. Go to Solution.
Solved by paullimapa. Go to Solution.
code already written in this thread
Just change the layerName:
(vla-add (vla-get-layers acDoc) (setq layerName "0-VPRT"))
To your LayerName:
(vla-add (vla-get-layers acDoc) (setq layerName "$X-ANNO-VPRT"))
sorry, is it possible to use AutoCAD command to do it? They can be used in script later, many thanks.
Unfortunately, other than LISP I don't know of a command line version that can select All Vports in All Layouts to change all of them to another Layer. Also the built-in AutoCAD commands QSELECT and FILTER require dialog user entry to select the object type.
Do you still have old LT versions that are not 2024 which don't support lisp but only script files?
Most case. there is only one Vport, one layout in the drawing. We can consider only change one Vport, one layout, thanks.
I still don't know of an AutoCAD command line that can select and filter out a VPort object from all other objects in a layout.
One trick if you know the layer name that the VPort is currently on then the SelectSimilar command can be used. Assuming current VPort is on layer name "SET-VP" and layer name "$X-ANNO-VPRT" does not exist in the dwg then the following Script will work:
_.Tilemode
0
_.Pspace
.-Layer
_M
$X-ANNO-VPRT
_Set
SET-VP
_.Mview
0,0
1,1
_.SelectSimilar
_L
_.Chprop
_LA
$X-ANNO-VPRT
_CO
_BYLAYER
_.Erase
_L
Update. Found the SELECTSIMILARMODE system variable that can be changed on the command line to impact SELECTSIMILAR command settings.
So you can now run this Script file without knowing what the current Vport layer name is:
SELECTSIMILARMODE
128
_.Tilemode
0
_.Pspace
.-Layer
_M
$X-ANNO-VPRT
_.Mview
0,0
1,1
_.SelectSimilar
_L
_.Chprop
_LA
$X-ANNO-VPRT
_CO
_BYLAYER
_.Erase
_L
O you should know how to add that but here's yet another improved version without messing with SelectSimilar settings but instead rely only on AutoCAD's built-in MView command:
_.Tilemode
0
_.Pspace
.-Layer
_M
$X-ANNO-VPRT
_.Mview
_On
_All
_.Chprop
_P
_LA
$X-ANNO-VPRT
_CO
_BYLAYER
_.DRAWORDER
_P
_Front
Great job! Sorry to bother you, can I ask you one more question? If I want to add this script to Macro, how to modify it? many thanks.
Try this:
^C^C_.Tilemode;0;_.Pspace;.-Layer;_M;$X-ANNO-VPRT;;_.Mview;_On;_All;;_.Chprop;_P;;_LA;$X-ANNO-VPRT;_CO;_BYLAYER;;_.DRAWORDER;_P;;_Front;
Original is below and it works,
^C^C-LAYER;LOCK;$X-ANNO-VPRT;LOCK;$X-ANNO-VPRT;;MVIEW;L;ON;ALL;;
new one is below, it did not work.
^C^C-LAYER;LOCK;$X-ANNO-VPRT;LOCK;$X-ANNO-VPRT;;MVIEW;L;ON;ALL;;_.Tilemode;0;_.Pspace;.-Layer;_M;$X-ANNO-VPRT;;_.Mview;_On;_All;;_.Chprop;_P;;_LA;$X-ANNO-VPRT;_CO;_BYLAYER;;_.DRAWORDER;_P;;_Front;;
thanks a lot!
It's possible that what I provided would fail if the current Vport's Layer is Locked.
Since you don't know what layer the current Vport is on, this means the new macro would have to include the Layer command to Unlock All Layers. Then at the end add back Layer Lock $X-ANNO-VPRT which is what the following macro should do:
^C^C_.Tilemode;0;_.Pspace;.-Layer;_Unl;*;;_.Mview;_L;_ON;_ALL;;_.Chprop;_P;;_LA;$X-ANNO-VPRT;_CO;_BYLAYER;;_.DRAWORDER;_P;;_Front;.-Layer;_Lo;$X-ANNO-VPRT;;
So you don't need to include your original macro. The above should take care of locking both the layer & the vport
Hi there, the original Macro can only lock the Vport display. Sorry about it, it has some problems. In Macro "$" character is used for different function, so its causing a problem.
Someone created a lisp for it, it is not perfect, it works, many thanks.
Of course you can run LL automatically after loading. But I also changed the sequence of the lines in your code to make it work. Again since your code does NOT include an option to UnLock ALL Layers the changing of the Vport Layer ONLY works if the Layer the Vport is on is NOT locked:
(defun c:LL()
; Layer Make sets Layer current
(Command "_.-LAYER" "_MAKE" "$X-ANNO-VPRT" "")
; Layer New creates Layer but does not set as current so you decide which one you want to use
;(Command "_.-LAYER" "_NEW" "$X-ANNO-VPRT" "")
; You can continue the Layer Lock as part of above code or start new command like this
; Layer Locks the Vport layer
(Command "_.-LAYER" "_LOCK" "$X-ANNO-VPRT" "")
; Now before running Mview command you need to first set Tilemode to 0
(COMMAND "_.TILEMODE" "0")
; then make sure is in Paper space & not in Model space inside a Vport
(Command "_.PSPACE")
; now run Mview command to Lock & turn On all Vports in current Layout
(Command "_.MVIEW" "_LOCK" "_ON" "_ALL" "")
; Chprop command Previous will only succeed if the current Vport's Layer is NOT Locked and there are Vports found in the current Layout
(Command "_.CHPROP" "_P" "" "_LAYER" "$X-ANNO-VPRT" "_COLOR" "BYLAYER" "")
; Draworder command only works if there are Previous Vports found
(Command "_.DRAWORDER" "_P" "" "_FRONT")
(princ)
)
; automatically run the command
(c:LL)
Great! It works perfect! Another lisp has minor changes, I lost the original link. Can I post here or make a new post? Finally, I want to combine two lisps together, many thanks.
Best to start a new post on that lisp
Glad to have helped…cheers!!!
Can't find what you're looking for? Ask the community or share your knowledge.