Recent Posts

Pages: [1] 2 3 ... 10
1
CAD General / Re: Parcing a filename into a block
« Last post by Lee Mac on Today at 02:03:41 pm »
First,  Thank you for all the assitance you have provided for all my other projects.. I visit your site OFTEN, and am more than mildly impressed with your work.

Thank you DIW, I appreciate your gratitude & compliments  :-)

The hope of this, is to minimize us opening and closing of files when/if the dwg's name is changed by the engineer.  I.E.  Instead of opening 60 DWG's to perform the change, we just change the number in Windows Explorer.  As well as for use in our template drawing, so this can be automated on newly created DWG's.  This would be especially handy when copying drawings from older project to newer projects and renaiming.  So, I would definitly prefere some form of Field Expression, and or DIESEL code. With the use of the LSP it will still require opening the drawing and performing a function, and the lisp would have to be installed on ever CAD technicians machine, both here and in KC.  This could be problematic to coordinate/educate CAD technicians.  The Field Expresson and Diesel code would be much cleaner operationally across the board.  Although, from the results of my searching, seemingly much more difficult.

Do you think this is impossible with Field Expressions or DIESEL .. or even Rtext?

Regarding the possibility of using Fields (which includes DIESEL):

  • If the hyphens in the filename were commas -> yes.
or
  • If the sections of the filename were of fixed length -> yes.

Otherwise, I would say no, since DIESEL does not offer a means of reporting the position of a character in a string.

Regarding the LISP solution:

With the use of the LSP it will still require opening the drawing and performing a function

Firstly, note that a solution using fields would still require you to open each drawing in order to update the attribute fields (that is, the field will only be 'recalculated' when the drawing is next opened).

However, a LISP solution would operate in an identical manner - you would simply include the above code in an acaddoc.lsp saved to a network support path and the code would automatically run on drawing startup to update the necessary attribute values - there would be no user input required, only an initial setup.

Lee
2
CAD General / Re: Parcing a filename into a block
« Last post by DIW_CADtech on Today at 01:04:58 pm »
Mr. Lee,

First,  Thank you for all the assitance you have provided for all my other projects.. I visit your site OFTEN, and am more than mildly impressed with your work.

That being said,

The hope of this, is to minimize us opening and closing of files when/if the dwg's name is changed by the engineer.  I.E.  Instead of opening 60 DWG's to perform the change, we just change the number in Windows Explorer.  As well as for use in our template drawing, so this can be automated on newly created DWG's.  This would be especially handy when copying drawings from older project to newer projects and renaiming.  So, I would definitly prefere some form of Field Expression, and or DIESEL code. With the use of the LSP it will still require opening the drawing and performing a function, and the lisp would have to be installed on ever CAD technicians machine, both here and in KC.  This could be problematic to coordinate/educate CAD technicians.  The Field Expresson and Diesel code would be much cleaner operationally across the board.  Although, from the results of my searching, seemingly much more difficult.

Do you think this is impossible with Field Expressions or DIESEL .. or even Rtext?

Please advise.
3
It was on the calender for today, but will have to wait until tomorrow. A cursory look at the functions kind of make sense.
4
ronjonp,
You code didn't work.  Having cnt within the repeat command didn't work, so I brought that out in a different way.

But, the code crashes at the vl-some part.  I'm not familiar with vl-some enough to know what happened, but, I believe that it has something to do with if the parameter "AFF" is not in the block, then vl-some crashes.

I've attached the two blocks that I'm working with (R2012). I will eventually have to have the code work with both blocks.  In older drawings, "DaBlock" will be used.  In newer drawings, "DaBlockNew" will be used.  Biggest problem is that they both will have the same name "DaBlock".  I'm only using DaBlockNew to make it easier to work with here.  Hence why I'm looking for something that is different in the two so that the code can tell them apart.  Only thing I could think of was the missing parameter "AFF" would tell the code that it's working with an old block and it needs to be replaced by the new block.

Also, notice that the blocks have different insertion points.  As if the rest wasn't hard enough.


Here's you code showing what I did with the cnt. (lines 2-4 have changed)
Code - Auto/Visual Lisp: [Select]
  1. (defun c:foo (/ cnt e o pts xlist)
  2.  (if (setq cnt (sslength (setq xlist (ssget "X" (list (cons 0 "INSERT") (cons 2 "ELEVATION - NEW ORB,`*U*"))))))
  3.    (repeat (sslength xlist)
  4.      (setq cnt (1- cnt))
  5.      (if
  6.        (= (strcase
  7.             (vla-get-effectivename (setq o (vlax-ename->vla-object (setq e (ssname xlist cnt)))))
  8.           )
  9.           "ELEVATION - NEW ORB"
  10.        )
  11.         (if (vl-some (function (lambda (_prop) (= "BotORBToFlr" (strcase (vlax-get _prop 'name)))))
  12.                      (vlax-invoke o 'getdynamicblockproperties)
  13.             )
  14.           (entdel e)
  15.           (setq pts (cons (vlax-get o 'insertionpoint) pts))
  16.         )
  17.      )
  18.    )
  19.  )
  20.  (princ))
  21.  
  22.  
5
See if this helps you out. *untested*
Code - Auto/Visual Lisp: [Select]
  1.  
  2. (defun c:foo (/ cnt e o pts xlist)
  3.  (if (setq xlist (ssget "X" (list (cons 0 "INSERT") (cons 2 "dablock,`*U*"))))
  4.    (repeat (setq cnt (1- (sslength xlist)))
  5.      (if
  6.        (= (strcase
  7.             (vla-get-effectivename (setq o (vlax-ename->vla-object (setq e (ssname xlist cnt)))))
  8.           )
  9.           "DABLOCK"
  10.        )
  11.         (if (vl-some (function (lambda (_prop) (= "AFF" (strcase (vlax-get _prop 'name)))))
  12.                      (vlax-invoke o 'getdynamicblockproperties)
  13.             )
  14.           (entdel e)
  15.           (setq pts (cons (vlax-get o 'insertionpoint) pts))
  16.         )
  17.      )
  18.    )
  19.  )
  20.  (princ))
6
Dynamic Blocks / Re: using 'cal in a stretch grip dialogue box
« Last post by mjfarrell on Today at 12:10:18 pm »
WORKS FOR ME AS EXPECTED.....Command:
Specify point location or [Base point/Undo/eXit]: 'CAL

>>>> Expression: 3*(2+5)

Resuming GRIP_STRETCH command.

Specify point location or [Base point/Undo/eXit]: 21


issue is when and or where you enter your value....in the DYN box it will behave NOT as expected
@ command line it will
7
AutoLISP (Vanilla / Visual) / Re: Changing anonymous block with another block
« Last post by GP on Today at 11:58:47 am »
Try:

Code: [Select]
(setq xlist (ssget "_X" (list '(0 . "INSERT") (cons 2 (strcat "`*U*," "DaBlock")))))
8
Dynamic Blocks / Re: using 'cal in a stretch grip dialogue box
« Last post by Albroswift on Today at 11:55:31 am »
 I attached the drawing with a sample block, if you would like to try.
Quote
Interestingly enough...using the STRETCH command on a normal rectangle does not produce the results you describe:
Yes, a line or rectangle behaves as you say ie click a line, grab the end grip, type 10, line increases in length by 10.
But, click on the stretch grip on my block, type 10, block resizes to 10 in that axis.
I am using the word axis as I have a stretch in the x axis and the y axis, but applies to any stretch command in any dynamic block as far as I can determine.
Quote
>>>> Expression: 2*12

stretches the box 24 units as expected

Specify second point or <use first point as displacement>: 'cal

>>>> Expression: (10+2)*3

results as expected

Can't enter a formula in a dynamic block stretch without the 'cal
Try my block, see what you think.
[quote}dynamic block with stretch function constrained to a(n) axis is how I am reading this[/quote]
Correct
9
can't help thinking about daBlock and daBears
10
AutoLISP (Vanilla / Visual) / Changing anonymous block with another block
« Last post by Rabbit on Today at 11:49:56 am »
I've spent way more time that necessary trying to figure out how to do it.  My biggest obstacle is just getting the anonymous blocks and then processing them to make sure they are the correct block.

Here's the situation:  In my drawing template, I have a dynamic block, it's name is "DaBlock".  This block is going to change in future version, but, I need for my lisp routines to handle this block in a legacy fashion.  So, my idea is to look at the name of stretch parameters find the one that is called "AFF", which is in the new version of the block.  If "DaBlock" has parameter "AFF", then do this code, otherwise do that code.  Simple.  Nope.  "DaBlock" is an anonymous block.  I cannot for the life of me figure out how to do a SSGET "X" for anonymous block "*UXXXX", when the only thing I have to go by is "DaBlock" 

----hmmmmmm
While writing this, I came up with something, but it doesn't work either because I have a version of "DaBlock" inside of another block.  And, I think entdel is crashing too.  Here's what I tried:

Code - Auto/Visual Lisp: [Select]
  1. (setq xlist (ssget "X" (list (cons 0  "INSERT"))))
  2.      (repeat (setq cnt (1- (sslength xlist)))
  3. (if (= (vla-Get-EffectiveName (vlax-ename->vla-object (ssname xlist cnt))) "DaBlock" )
  4.  (setq goodset (cons (ssname xlist cnt) goodset))))
  5.  
  6.      (repeat (setq cnt (1- (length goodset)))
  7. (if (not (assoc "AFF"
  8.  (function (lambda ( _prop ) (cons (vla-get-propertyname _prop) (vlax-get _prop 'Value))))
  9.  (vlax-invoke (vlax-ename->vla-object (nth cnt goodset)) 'GetDynamicBlockProperties)
  10. );mapcar
  11.    ))
  12.  (progn;get insertion points and delete old blocks
  13.    (setq InsPntList (cons (safearray-value (variant-value (vla-get-insertionpoint (vlax-ename->vla-object (nth cnt goodset))))) InsPntList))
  14.    (entdel (nth cnt goodset))
  15.  );progn
  16. )
  17. );repeat
  18.  
  19.      (coomand "-purge" "B" "*" "N")
  20.  
  21.      (foreach item InsPntList)
  22. (command "_insert" "C:\\Folder\\DaBlock.dwg" item 1 1 0.0))
  23.  
  24. ;;;Another obstacle is that the new block and old block have different insertion points.
  25.  
Pages: [1] 2 3 ... 10