Recent Posts

Pages: [1] 2 3 ... 10
Vertically Challenged / How to add parts folder to parts catalog
« Last post by Alien on Today at 04:49:30 am »
I have a folder of parts i need to add to my parts catalog. Anyone know how I can do this? Simply copying the folder into the directory doesn't  appear to be working.
Very quickly modified from this:

Works...may have to reverse your lines... might be better to isolate your lines do offsets for all one side then the other...or if I have time will put routine up that will allow time to select side of lines for each offset

Code - Auto/Visual Lisp: [Select]
  1. (defun c:test (/ ent dist2 dist obj kwrd)
  2.  (vl-load-com) ;<-good!
  3.  (while (not ent) ;<- this sort of loop is hard to get out of, see my code
  4.    (if (eq (setq ent (car (entsel "\nSelect line to offset:  "))) ;<- (if (not (setq...)))
  5.    nil ;<- testing for nil is unneeded, use LISP's return values directly
  6. )
  7.      (princ "\nThat was not a line.  Please select again:  ") ;<- what if I pick a circle?
  8.    )
  9.  )
  10.  (initget (+ 1 2 4 64)) ;<- use of the Z-blocker was nice
  11.  (setq dist (getdist "\nEnter offset distance:  "))
  12.  (setq dist2 (getdist "\nDistance 2"))
  13.  (initget (+ 2 4) "Yes No") ;<- bits 2 and 4 server no purpose in (getkword)
  14.  (setq kwrd (getkword "\nDelete original object [Yes/No] <Yes>:  ")) ;<- 2000-style options, good!
  15.  (if (/= kwrd "No") ;<- this statement is unneeded, see below
  16.    (setq kwrd "Yes")
  17.  )
  18.  (setq obj (vlax-ename->vla-object ent))
  19.  (vla-offset obj dist)
  20.  (vla-offset obj (* dist2 -1))
  21.  (if (eq kwrd "Yes") ;<- (/= kwrd "No")
  22.    (vla-erase obj)
  23.  )
  24.  (princ)
  25. )
.NET / Re: How to add random messages to drawing
« Last post by Alien on Today at 02:21:23 am »
Thanks Kerry! didn't even know where to start :) Much appreciated.
.NET / Re: How to add random messages to drawing
« Last post by Kerry on Today at 01:51:13 am »
Perhaps do some research on the ExtensionDictionary.
.NET / Re: Change alignment of MText but retain actual text position
« Last post by Alien on Today at 01:38:01 am »
Can't help but will tell you I've tried a hundred times to deal with text styles and properties with .Net and there's always some little bug, something in the drawing, or the code, or whatever that makes it a pain in the booty.   I decided to stick with autolisp functions for them.


I've built an AutoCAD Plugin that replaces some DBText and MText Objects with an attributed block. My problem: Some of the MText have their alignment set to "Top left" and some have it set to "Bottom left".
The block that replaces the MText is designed so that it perfectly matches the text position if it was set to "Bottom Left" - since the majority of MText objects is drawn this way; I'd like to change all the MText alignments to "Bottom Left", so I can use the same block for all MText objects.

When I change the alignment in AutoCAD, the actual text position stays the same - the alignment property is set to a new value and the text is moved to the new position, so that the position of the letters stays the same <- That's what I'm trying to accomplish :)

Can someone get me started on how to do this? I'm not sure how to tackle this one... Below I have attached a small test command to change the .Attachment of the MText's.

Code: [Select]
        public void MTextJustificationTest()
            Database db = Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument.Database;
            Editor ed = Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument.Editor;

            Point3d startPos = new Point3d();

            using (Transaction tr = db.TransactionManager.StartTransaction())
                TypedValue[] filterDxf = new TypedValue[]
                    new TypedValue((int)DxfCode.Start,"MTEXT")
                SelectionFilter selectionFilter = new SelectionFilter(filterDxf);
                PromptSelectionResult psr = ed.SelectAll(selectionFilter);
                SelectionSet selectionSet = psr.Value;

                foreach (var objId in psr.Value.GetObjectIds())
                    MText mText = tr.GetObject(objId, OpenMode.ForWrite) as MText;
                    if (mText.Attachment != AttachmentPoint.BottomLeft)
                        startPos = mText.Location;
                        // How to get the _real_ text position?
                        mText.Attachment = AttachmentPoint.BottomLeft;

.NET / How to add random messages to drawing
« Last post by Alien on Today at 01:35:54 am »
I was thinking it would be cool if I could add notes to a drawing that I could review any time I open it... but not sure where I'd have to store them? Looking for a way to do it without text in my drawing.  Anyone know how to do this that can point me in the right direction?
AutoLISP (Vanilla / Visual) / Re: Rotate UCS into viewport
« Last post by Kerry on August 29, 2015, 01:25:18 pm »

That is really disappointing.

You come here and ask for help, ask for people to take time and effort to resolve a problem you have.
Then you excuse yourself for your lack of effort to explain how the issue was resolved, completely denying future readers of this thread the benefit of a solution you crafted.

AutoLISP (Vanilla / Visual) / Re: the relation of point in modelspace and paperspace
« Last post by Lupo76 on August 29, 2015, 12:09:48 pm »
Thank you all,
in fact the code of Gile, works properly.

I had made some mistakes in my code.
I apologize if I have wasted your time
AutoLISP (Vanilla / Visual) / Re: Rotate UCS into viewport
« Last post by Lupo76 on August 29, 2015, 11:44:19 am »
That's great!
How did you do it ??

I just adopted a totally different system to do what I had to do.
Any explanation would be too long, and however OT
You may want to consider combining all LAyer calls vs calling (command "_.LAYER") multiple times :

Code - Auto/Visual Lisp: [Select]
  1. ;;Provide used layers
  2. (command "_.LAYER")
  3. (foreach l (list (list "GasUtilitiesCombo"     "2" "CONTINUOUS")
  4.                 (list "GasUtilitiesStorm"    "64" "CONTINUOUS")
  5.                 (list "GasUtilitiesSanitary" "26" "CONTINUOUS")
  6.                 (list "GasUtilitiesWater"   "171" "CONTINUOUS"))
  7.  (if (not (tblsearch "LAYER" (nth 0 l)))
  8.      (command "_Make"  (nth 0 l)
  9.               "_Color" (nth 1 l) (nth 0 l)
  10.               "_LType" (nth 2 l) (nth 0 l))))
  11. (command "")

Editing / maintaining a master list works better for me

Pages: [1] 2 3 ... 10