Professional Documents
Culture Documents
Skip to content
Home
About
Website Links
Create New Objects with AddSelected
Posted on August 25, 2018by AutoCAD Tips
The tool ADDSELECTED has been in AutoCAD since ACAD 2011 and It has
saved me a lot of time.
Regardless of your current settings, such as Layer, Dim Style, Text Style… You
can easily recreate an existing object by simply selecting the object, Right-click
and select “Add Selected” from the right-click menu.
In the video below, I create a new dimension and a new center line without
knowing what layer or style they have. Even if the object has property overrides
such as color, linetype, Linetype Scale… Add Selected will set those properties
and start the command for you to create a similar object.
~enjoy
;;; Changes the selected XREF's Layer color to AutoCAD Color 253 in the current
drawing only
;;; Useful for Existing Base (E-Base) XREFs
(defun c:XR253 (/ xr1 xr2 xr3 xr4 xr5 xr6 tx1 tb1)
(if (setq
xr1 (entsel "\nSelect Xref to change all layers to color 253: ") ;; <---
Change color number as needed
) ;_ end of setq
(progn
(setq xr2 (entget (car xr1)))
(setq tx1 (cdr (assoc 0 xr2)))
(if (and (= tx1 "INSERT")
) ;_ end of and
(progn
(setq xr3 (cdr (assoc 2 xr2)))
(setq xr4 (tblsearch "block" xr3))
(if (setq xr5 (cdr (assoc 1 xr4)))
(progn
(setq xr6 (strcat xr3 "|*"))
(command "-layer" "c" "253" xr6 "") ;;; <---Change color number as
needed
) ;_ end of progn
(prompt (strcat "\n" xr3 " is not an X-Ref."))
) ;_ end of if
) ;_ end of progn
(prompt "\nNo valid XREF selected")
) ;_ end of if
) ;_ end of progn
(princ " ...Nothing selected")
) ;_ end of if
(princ)
)
Posted in AutoLISP, AutoLISP XREFs, XREFs | 7 Comments
As seen below, The issue seems to be only one triangle that is repeated.
Here is a good rule of thumb when it comes to AutoCAD. The further away your
drawing elements are from the “Origin” (0,0,0) the more weird stuff tends to
happen in your drawing. And since Civil 3D works in real-world coordinates,
our drawings are far away from the origin. I live in the Denver Colorado area, so
my drawings are not only far from zero, zero but also the 3rd zero as we are a
mile high…
Luckily, there is an easy solution to this. You can give hatches a new origin while
leaving your UCS alone.
Simply select the hatch so that the “Hatch Editor” contextual tab is shown, Then
click on “Set Origin” as shown below and then click on a point that is within the
area where your drawing objects are located. I would suggest using a common
point as the new origin. Something like the corner of a building. That way if you
have two areas that are hatched separately but are right next to each other, they
will have the same pattern.
Enjoy!
Posted in BASICS, Civil 3D, Civil 3D Tips, Hatch, Modifying, TIPS, Uncategorized | 6 Comments
Does your drawing have holy hatches? Some of the drawings I work on have
these annoying outline/remnants of objects that have been moved or deleted.
And now I have to clean them up.
Some of these objects could have been geometry that has moved, but the most
common culprit is text objects that were included when the hatch was made.
Some people opt for this method as a way of masking their text. But the problem
with that method is what we are dealing with in this blog post – holes in the
hatch.
Select the hatch or use the command HATCHEDIT first and then select
the hatch.
Click the “Remove” button in the “Hatch Editor” contextual ribbon tab.
Select the boundaries that you want to be removed.
Hit enter to finish
As a side note, if you need to include an object, you can click the “SELECT”
button to add objects to the hatch.
Posted in Hatch, Modifying, TIPS | 3 Comments
Here is a LISP routine that lets you do the same thing without having Civil 3D.
The LISP routine is found at the swamp.org and is by Joe Burke, Charles Alan
Butler and VovKa.
Here’s How:
;; Version history:
;; Returns the coordinates of the current view, lower left and upper right.
;; Works in a rotated view. Returns a list of two 2D UCS points.
(defun MD:GetScreenCoords ( / ViwCen ViwDim ViwSiz VptMin VptMax)
(setq ViwSiz (/ (getvar "VIEWSIZE") 2.0)
ViwCen (getvar "VIEWCTR")
ViwDim (list
(* ViwSiz (apply '/ (getvar "SCREENSIZE")))
ViwSiz
)
VptMin (mapcar '- ViwCen ViwDim)
VptMax (mapcar '+ ViwCen ViwDim)
)
(list VptMin VptMax)
) ;end
;; Arguments:
;; p1 - WCS or UCS point which defines the first corner of area
;; p2 - WCS or UCS point which defines the second corner of area
;; pt - point translated to UCS.
;; Returns: T if pt falls within area.
(defun MD:PointInside (p1 p2 pt / xval yval)
(and
pt
(setq pt (trans pt 0 1)
xval (car pt)
yval (cadr pt)
)
(< (min (car p1) (car p2)) xval (max (car p1) (car p2)))
(< (min (cadr p1) (cadr p2)) yval (max (cadr p1) (cadr p2)))
)
) ;end
(defun c:MinDist ( / *error* doc blocks units obj1 obj2 typ1 typ2 pkpt p2 sc
div fuzz d bd len inc idx resdist dellst res1 res2 pts
locklst interflag z1 z2 diff temp reverseflag
MD:Wait MD:NormalAngle MD:ParallelObjects MD:Pick
MD:GetXrefs MD:UnlockLayers MD:RelockLayers MD:GetObject
MD:XMark MD:UniformScale MD:XlineOrRay)
;; global vars: *mdp1* and *mdpt*
(vl-load-com)
(setvar "errno" 0)
(while
(or
(not (setq e (nentselp msg)))
(not (setq obj (vlax-ename->vla-object (car e))))
(not (vl-position (setq typ (vlax-get obj 'ObjectName)) typlst))
(and
(cadddr e)
(not (apply 'and (mapcar 'MD:UniformScale (last e))))
(setq scflag T)
)
)
(cond
((= 52 (getvar "errno"))
(exit)
)
((not e)
(princ "\nMissed pick. ")
)
(scflag
(princ "\nNon-uniformly scaled block detected, try again. ")
(setq scflag nil)
)
(typ
(princ (strcat "\n " (substr typ 5) " selected, try again. "))
(setq typ nil)
)
)
)
(if
(or
(eq "AcDb2dVertex" typ)
(eq "AcDb3dPolylineVertex" typ)
)
(setq obj (vlax-ename->vla-object (cdr (assoc 330 (entget (car e)))))
typ (vlax-get obj 'ObjectName)
)
)
;;;; Sub-functions...
(foreach x lst
(if
(and
(setq p (inters basept secpt (car x) (cadr x) nil))
(inters basept p (car x) (cadr x))
)
(setq pts (cons p pts))
)
)
(cond
((eq "AcDbXline" typ)
(setq expt1 (polar (cadr pts) (angle (cadr pts) (car pts)) (* 2 d))
expt2 (polar (car pts) (angle (car pts) (cadr pts)) (* 2 d))
pts (reverse (list expt1 expt2))
)
)
;; Revised 6/29/2008
((eq "AcDbRay" typ)
(setq expt1 (MD:FarthestPoint basept pts)
expt1 (polar expt1 (angle basept secpt) (* 2 d))
pts (list basept expt1)
)
;; If base point is far away attempt to get a closer point
;; by testing for param at point.
(setq expt2 (polar expt1 (angle secpt basept) (* 5 d)))
(if (vlax-curve-getParamAtPoint obj (trans expt2 1 0))
(setq pts (reverse (list expt2 expt1)))
)
)
)
;; Trans UCS points to WCS as needed.
(mapcar '(lambda (x) (trans x 1 0)) pts)
) ;end MD:XlineOrRay
(vla-StartUndoMark doc)
(sssetfirst)
(princ "\nSelect line, circle, arc, ellipse, polyline, spline, point, ray or xline.")
(if
(and
(setq res1 (MD:Pick "\nFirst object: "))
(setq typ1 (cadr res1))
(princ (substr typ1 5))
(setq obj1 (MD:GetObject res1))
(not (vla-highlight obj1 acTrue))
;; Get the screen coordinates here in case
;; the user pans between select objects.
(if
(or
(eq "AcDbRay" typ1)
(eq "AcDbXline" typ1)
)
(setq sc (MD:GetScreenCoords))
T
)
(setq res2 (MD:Pick "\nSecond object: "))
(setq typ2 (cadr res2))
(princ (substr typ2 5))
(setq obj2 (MD:GetObject res2))
)
(progn
(cond
((equal obj1 obj2)
(princ "\n Same object selected twice. ")
(setq resdist 0.0
interflag T
)
)
((vlax-invoke obj1 'IntersectWith obj2 acExtendNone)
(princ "\n Objects intersect. ")
(setq resdist 0.0
interflag T
)
)
((and
(eq typ1 "AcDbPoint")
(eq typ2 "AcDbPoint")
)
(setq *mdpt* (vlax-get obj1 'Coordinates)
*mdp1* (vlax-get obj2 'Coordinates)
d (distance *mdpt* *mdp1*)
)
)
((or
(eq typ1 "AcDbPoint")
(eq typ2 "AcDbPoint")
)
(if (eq typ1 "AcDbPoint")
(setq *mdpt* (vlax-get obj1 'Coordinates)
*mdp1* (vlax-curve-getClosestPointTo obj2 *mdpt*)
)
(setq *mdpt* (vlax-get obj2 'Coordinates)
*mdp1* (vlax-curve-getClosestPointTo obj1 *mdpt*)
)
)
(setq d (distance *mdpt* *mdp1*))
)
;; Core stuff follows.
(T
(if
(or
(eq typ2 "AcDbRay")
(eq typ2 "AcDbXline")
)
;; Reverse the objects and set a flag to reverse
;; the points later.
(setq temp obj1 obj1 obj2 obj2 temp reverseflag T)
)
(*error* nil)
) ;end MinDist
;shortcut
(defun c:MD () (c:MinDist))
;; Added 8/24/2008.
;; Allows a selection set to be moved from the first MinDist point to
;; the second MinDist point. So the order of object selection within
;; MinDist is important in terms of which way the selection set will move.
;; IOW, if the user anticipates using this function after MD, the first object
;; selected determines move from point. The second object selected is
;; the move to point.
(defun c:MinDistMove ( / *error* doc osm ss)
;; Revised 6/30/2008.
;; Draw minimum distance line on the current layer.
(defun c:MinDistLine ( / d sc ss)
(cond
((not (and *mdpt* *mdp1*))
(princ "\n Minimum distance points not found. Run MD and then MDL to draw
line.")
)
((and
(setq d (distance *mdpt* *mdp1*))
;(print d) ;testing
(< d 1e-5)
)
(princ "\n Minimum distance points are too close together. ")
)
(T
(entmake
(list
'(0 . "LINE")
(cons 8 (getvar "clayer"))
(cons 10 *mdpt*)
(cons 11 *mdp1*)
)
)
(setq sc (MD:GetScreenCoords))
(if
(or
(MD:PointInside (car sc) (cadr sc) *mdpt*)
(MD:PointInside (car sc) (cadr sc) *mdp1*)
)
(princ "\n Minimum distance line placed. ")
(progn
(princ "\n Minimum distance line placed off screen and selected. ")
(sssetfirst nil (setq ss (ssget "L")))
)
)
)
)
(princ)
) ;end MinDistLine
;shortcut
(defun c:MDL () (c:MinDistLine))
Posted in AutoLISP, AutoLISP: Creating, AutoLISP: Dimensions, Uncategorized | 5 Comments
While working on some road access areas that lead into parking lots, I need to
find and measure the closest points between two objects to verify that cars &
trucks can fit in the lane.
Shown below is an example of an access point along a roadway. These are not
parallel, so I am unable to measure at a nearest spot along a curb and find the
distance perpendicular to the other side of the road.
The handy tool that is found within Civil 3D is found on the “Analyze” tab and in
the “Inquiry” panel’s dropdown list. The tool is named a long one… “Minimum
Distance Between Entities”
~Enjoy
Posted in Civil 3D, Civil 3D Tips, Uncategorized | 3 Comments
Search
Recent Posts
Create New Objects with AddSelected
Change XREF Layer Colors to One Color
Fixing Your Broken Concrete Hatch Pattern
Fix Your AutoCAD Hatch Holes
LISP version of Closest Distance Between Two Objects
Follow Blog via Email
Enter your email address to follow this blog and receive notifications of new posts by email.
Sign me up!
Archives
August 2018
March 2018
July 2017
March 2017
September 2016
August 2016
July 2016
March 2016
December 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
October 2013
September 2013
August 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
December 2010
November 2010
Top Posts
Embed a Picture (Not as a Reference)
Rotating your UCS
The Select and Previous Commands in AutoCAD
How to Fix Blocky Circles & Arcs
Adding Text to your Dim
AutoLISP: Merge Hatches Join Hatches
AutoLISP: Split Dimensions
Changing A Block Insertion Point
AutoLISP: Make and Save Custom Hatch Pattern
AutoLISP: Combine Text
Categories
3D Intro
April Fools
Attributes
AutoCAD 2013
AutoCAD 2015
AutoCAD for Mac
Autodesk University
AutoLISP
AutoLISP XREFs
AutoLISP: 3D
AutoLISP: Attributes
AutoLISP: Blocks
AutoLISP: Creating
AutoLISP: Dimensions
AutoLISP: Manage
AutoLISP: Modify
AutoLISP: Polylines
AutoLISP: Text
BASICS
Blocks
CADWorx
Civil 3D
Civil 3D Tips
Customization
Dimensions
Express Tools
Hatch
Isometrics
Layers
Layout
Leaders
Linetypes
Manage
Modifying
multileaders
Navisworks
New in 2011
New in 2012
New In 2013
New in 2014
New in 2015
New in 2016
New in 2017
OLE Objects
Paper Space
PDF
Polylines
Portfolio
Printing – Plotting
Raster Design
Revit
Scripts
Settling In
Tables
Text
TIPS
Tool Palletes
Trouble Shooting
Uncategorized
Updated
User Interface
Viewports
Wipeouts
Workspaces
XREFs
Meta
Register
Log in
Entries RSS
Comments RSS
WordPress.com
AutoCAD Tips Twitter
For all of the guys out there that are outnumbered at home by girls: Thank me
later...shop.charmin.com/starter-kits3 months ago
@TheMadCadr @Lynn_Allen This is so cool!! Way to go @Lynn_Allen 3 months ago
@SteveJohnsonCAD Wow!!! 6? They outdid themselves this time3 months ago
@C3DPlus Yup 3 months ago
AutoCAD Tips
Create a free website or blog at WordPress.com.
Close and accept
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to
their use.
To find out more, including how to control cookies, see here: Cookie Policy