MikeT Posted January 22, 2009 Posted January 22, 2009 Hello all, I have googled a lot to find a solution for my problem. So far this place looks the best promising place to find answears. I have exported from Solidworks a dwg drawing with true 3D dimension to Autocad drawing including lots of dimensions. My purpose is to do a little fixup for dimension lines and to deliver it to customer then. When I move the dimension line the dimension changes to real dimension what it measured from Autocad not the imported 3D dimension. I think that I must copy the imported dimension to text override and then fix dimensions. Doing manually this copy work to text override would take ages so I did a little lisp to help me but it did not work the way I wanted. This lisp does the work and copy the dimension to text override but the dimension is wrong. It is the dimension that autocad measures from picture not the imported 3D (cross-measure) dimension. I have never done lisp before so there must be a better way (and really working one) and maybe a way to select all measures from picture rather than one by one. (Defun c:dimchange () (setq newdim (entsel "\n Select Dimension to change:")) (setq newdimvalue "") (command "dimedit" "n" newdimvalue newdim "") (princ) ) Desperately seeking solution MikeT Quote
Lee Mac Posted January 22, 2009 Posted January 22, 2009 Hi Mike, Welcome to CADTutor. Just to clarify, You have a dimension in AutoCAD, and need to take off the dimension override? What exactly would you like the dimension to display, because taking off the dimension override will just set the dimension to what ACAD measures the distance to be (I'm sure you already knew that). Hope I can help Cheers Lee Quote
MikeT Posted January 22, 2009 Author Posted January 22, 2009 Hi, Maybe I was not enough specific. The dimensions are right in the exported drawing. If I try to move dimension line for more "better layout" that they are in Solidworks the measument changes to real value what Autocad measures in 2D Autocad. The aim was to copy this real original dimension value to text override and then able to fix placement of dimensions. Maybe I try to post a picture if I did not make my self clear this time ... MikeT Quote
VVA Posted January 22, 2009 Posted January 22, 2009 If I have correctly understood ;;Dim override (defun c:dimo (/ COPYDIM CURLAY DELSET DIMLST DIMSET ERRCOUNT LAYCOL LENT NEXTENT OVTEXT *ERROR* ACTDOC OLDECHO) ;;; Vladimir Smirnov {Smirnoff} on dwg.ru (defun *ERROR* (msg) (setvar "CMDECHO" oldEcho) ); end of error (vl-load-com) (setq oldEcho(getvar "CMDECHO") actDoc(vla-get-ActiveDocument (vlax-get-acad-object)) layCol(vla-get-Layers actDoc) ); end setq (setvar "CMDECHO" 0) (if (setq dimSet (ssget '((0 . "DIMENSION")))) (progn (setq dimLst (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr(ssnamex dimSet)))) errCount 0 ); end setq (vla-StartUndoMark actDoc) (foreach dim dimLst (setq curLay(vla-get-Layer dim)) (if (/= :vlax-true (vla-get-Lock(Col_Item_Find layCol curLay))) (progn (setq lEnt(entlast) delSet(ssadd) copyDim(vla-Copy dim) ); end setq (command "_.Explode"(entlast)) (setq nextEnt(entnext lEnt)) (while nextEnt (ssadd nextEnt delSet) (if (member (cdr(assoc 0(entget nextEnt))) '("TEXT" "MTEXT")); end member (setq ovText (cdr(assoc 1(entget nextEnt)))) ); end if (command "_.erase" nextEnt "") (setq nextEnt(entnext nextEnt)) ); end whlie (vla-put-TextOverride dim ovText) (vla-put-Color dim 22) ); end progn (setq errCount(1+ errCount)) ); end if ); end foreach (if(/= 0 errCount) (princ (strcat "\n" (itoa errCount)" were on locked layer!")) ); end if (vla-EndUndoMark actDoc) ); end progn ); end if (setvar "CMDECHO" oldEcho) (princ) ); end of c:dimr (defun Col_Item_Find (Collection Item / result) (if (not (vl-catch-all-error-p (setq result (vl-catch-all-apply 'vla-item (list Collection Item))))) result ); end if ); end of Col_Item_Find ;;; Dim restore (defun c:dimr (/ COPYDIM CURLAY DELSET DIMLST DIMSET ERRCOUNT LAYCOL LENT NEXTENT OVTEXT *ERROR* ACTDOC OLDECHO) ;;; Vladimir Smirnov {Smirnoff} on dwg.ru (defun *ERROR* (msg) (setvar "CMDECHO" oldEcho) ); end of error (vl-load-com) (setq oldEcho(getvar "CMDECHO") actDoc(vla-get-ActiveDocument (vlax-get-acad-object)) layCol(vla-get-Layers actDoc) ); end setq (setvar "CMDECHO" 0) (if (setq dimSet (ssget '((0 . "DIMENSION")))) (progn (setq dimLst (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr(ssnamex dimSet)))) errCount 0 ); end setq (vla-StartUndoMark actDoc) (foreach dim dimLst (setq curLay(vla-get-Layer dim)) (if (/= :vlax-true (vla-get-Lock(Col_Item_Find layCol curLay))) (progn (vla-put-TextOverride dim "<>") (vla-put-Color dim 82) ); end progn (setq errCount(1+ errCount)) ); end if ); end foreach (if(/= 0 errCount) (princ (strcat "\n" (itoa errCount)" were on locked layer!")) ); end if (vla-EndUndoMark actDoc) ); end progn ); end if (setvar "CMDECHO" oldEcho) (princ) ) (princ "\nType Dimo to override and Dimr to restore") Color of the Dimensions is set in these lines (vla-put-Color dim 22) (vla-put-Color dim 82) Quote
Strix Posted January 22, 2009 Posted January 22, 2009 I'm probably being dim, but why are the real AutoCAD dimensions 'wrong'? would it not just be easier to scale the whole thing and allow the 'natural' dimensions to exist, or to alter the scale of the dimensions in the dimstyle? Quote
Lee Mac Posted January 22, 2009 Posted January 22, 2009 I'm probably being dim, but why are the real AutoCAD dimensions 'wrong'? would it not just be easier to scale the whole thing and allow the 'natural' dimensions to exist, or to alter the scale of the dimensions in the dimstyle? This baffled me also Quote
MikeT Posted January 22, 2009 Author Posted January 22, 2009 Hi, Nice to notice that questions really get answears in here. The dimensions are right in 3D space where line also goes in z-direction. Exported dwg picture from Solidworks is not a 3D picture but only 2D and the dimension Autocad gives is projected dimension. It is right dimension in 2D but it misses the transition to z-axel. I must make a "hand-out" inspection copy to working site where the actual work is done:) I will try that tomorrow at work. I have never ever manager to do this myself - many thanks. MikeT Quote
Lee Mac Posted January 22, 2009 Posted January 22, 2009 Just out of interest, would the "flatten" command (express) be of any use? Quote
flowerrobot Posted January 23, 2009 Posted January 23, 2009 is this what you want, (defun C:ov ( / ss ed dm dm1 ) (setq ss (ssget)) (setq ed (entget (setq e (entlast)))) (setq dm (cdr (assoc 42 ed)));get dim value (setq dm1 (rtos dm 2 0)) (command "dim1" "new" dm1 ss "") ) Quote
Strix Posted January 23, 2009 Posted January 23, 2009 why is it imported into ACAD as 2D though if it's giving you these problems? can't you export as 3D and save the bother? Quote
MikeT Posted January 23, 2009 Author Posted January 23, 2009 Hi all, and thanks for all of your replies. I tested both of the lisp codes and both of them did not the work quite right. VVA's code is very impessive and almost there but not quite. VVA's code inserts the acad measured dimension value in the text override not the exported value. flowerrobot's code puts -1 into every text override. In the inserted picture, there are dimensions captured from acad. The values in brackets are the real values (3D, z-axel) I want to put on the text override and the others are values acad measures from the drawing. I have manually entered the values in the drawing to clarify you. Flatted does not help since the drawing measurement is done in solidworks drawing mode (template). It represent the model in 2D but measures are from model. If customer wants acad drawings - customer gets acad drawings Maybe I have to make the dimensions "picture pefrect" in Solidworks and just export the drawing then. Although solidworks drawing making is not so accurate that it is in autocad. MikeT Quote
VVA Posted January 23, 2009 Posted January 23, 2009 Other version ;;Dim override (defun c:dimo (/ COPYDIM CURLAY DELSET DIMLST DIMSET ERRCOUNT LAYCOL LENT NEXTENT OVTEXT *ERROR* ACTDOC OLDECHO) ;;; Vladimir Smirnov {Smirnoff} on dwg.ru (defun *ERROR* (msg) (setvar "CMDECHO" oldEcho) ); end of error (vl-load-com) (setq oldEcho(getvar "CMDECHO") actDoc(vla-get-ActiveDocument (vlax-get-acad-object)) layCol(vla-get-Layers actDoc) ); end setq (setvar "CMDECHO" 0) (if (setq dimSet (ssget "_:L" '((0 . "DIMENSION")))) (progn (setq dimLst (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr(ssnamex dimSet)))) ); end setq (vla-StartUndoMark actDoc) (foreach dim dimLst (vla-put-TextOverride dim (dim-get-text-string (vlax-vla-object->ename dim))) (vla-put-Color dim 22) ) (vla-EndUndoMark actDoc) ); end progn ); end if (setvar "CMDECHO" oldEcho) (princ) ); end of c:dimo (defun Col_Item_Find (Collection Item / result) (if (not (vl-catch-all-error-p (setq result (vl-catch-all-apply 'vla-item (list Collection Item))))) result ); end if ); end of Col_Item_Find ;;; Dim restore (defun c:dimr (/ COPYDIM CURLAY DELSET DIMLST DIMSET ERRCOUNT LAYCOL LENT NEXTENT OVTEXT *ERROR* ACTDOC OLDECHO) ;;; Vladimir Smirnov {Smirnoff} on dwg.ru (defun *ERROR* (msg) (setvar "CMDECHO" oldEcho) ); end of error (vl-load-com) (setq oldEcho(getvar "CMDECHO") actDoc(vla-get-ActiveDocument (vlax-get-acad-object)) layCol(vla-get-Layers actDoc) ); end setq (setvar "CMDECHO" 0) (if (setq dimSet (ssget '((0 . "DIMENSION")))) (progn (setq dimLst (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr(ssnamex dimSet)))) errCount 0 ); end setq (vla-StartUndoMark actDoc) (foreach dim dimLst (setq curLay(vla-get-Layer dim)) (if (/= :vlax-true (vla-get-Lock(Col_Item_Find layCol curLay))) (progn (vla-put-TextOverride dim "<>") (vla-put-Color dim 82) ); end progn (setq errCount(1+ errCount)) ); end if ); end foreach (if(/= 0 errCount) (princ (strcat "\n" (itoa errCount)" were on locked layer!")) ); end if (vla-EndUndoMark actDoc) ); end progn ); end if (setvar "CMDECHO" oldEcho) (princ) ) (defun mip_MTEXT_Unformat ( Mtext / text Str ) (setq MM Mtext) (setq Text "") (while (/= Mtext "") (cond ((wcmatch (strcase (setq Str (substr Mtext 1 2))) "\\[\\{}]") (setq Mtext (substr Mtext 3) Text (strcat Text Str))) ((wcmatch (substr Mtext 1 1) "[{}]")(setq Mtext (substr Mtext 2))) ((wcmatch (strcase (setq Str (substr Mtext 1 2))) "\\[LO`~]") (setq Mtext (substr Mtext 3))) ((wcmatch (strcase (substr Mtext 1 2)) "\\[ACFHQTW]") (setq Mtext (substr Mtext (+ 2 (vl-string-search ";" Mtext))))) ((wcmatch (strcase (substr mtext 1 4)) "\\PQ[CRJD],\\PXQ") ;;;Add by KPblC (setq mtext (substr mtext (+ 2 (vl-string-search ";" mtext)))) ) ((wcmatch (strcase (substr Mtext 1 2)) "\\P") (if (or (zerop (strlen Text)) (= " " (substr Text (strlen Text))) (= " " (substr Mtext 3 1))) (setq Mtext (substr Mtext 3)) (setq Mtext (substr Mtext 3) Text (strcat Text " ")))) ((wcmatch (strcase (substr Mtext 1 2)) "\\S") (setq Str (substr Mtext 3 (- (vl-string-search ";" Mtext) 2)) Text (strcat Text (vl-string-translate "#^\\" "/^\\" Str)) Mtext (substr Mtext (+ 4 (strlen Str))))) (t (setq Text (strcat Text (substr Mtext 1 1)) Mtext (substr Mtext 2))))) Text) (defun dim-get-text-string ( dim / str) (setq str "") (vlax-for item (vla-item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)) ) ;_ end of vla-get-Blocks (cdr (assoc 2 (entget dim))) ) ;_ end of vla-item (if (vlax-property-available-p item 'Textstring) (setq str (vla-get-textstring item)) ) ) (mip_MTEXT_Unformat str) ) (princ "\nType Dimo to override and Dimr to restore") Quote
MikeT Posted January 26, 2009 Author Posted January 26, 2009 Hi I just tested it and ... it works perfectly Many thanks to VVA for know-how ! MikeT Quote
kkk Posted September 7, 2023 Posted September 7, 2023 hi all, i need a lisp program like if we type ss command in one dwg file it ask select dimensions orderly then press enter next open other dwg type vv command it ask select dimensions orderly to paste values then press enter so copy dimensions from one file to other file. Quote
Steven P Posted September 8, 2023 Posted September 8, 2023 On 9/7/2023 at 9:40 AM, kkk said: hi all, i need a lisp program like if we type ss command in one dwg file it ask select dimensions orderly then press enter next open other dwg type vv command it ask select dimensions orderly to paste values then press enter so copy dimensions from one file to other file. Ask this as a new topic, it is possible with a few different solutions, it might intrigue the community enough to make the whole LISp for you Quote
BIGAL Posted September 9, 2023 Posted September 9, 2023 (edited) The answer is in making a selection set of the dimension as made, then use copyclip, then you can paste into any other dwg, Blackboard also maybe. Do you really need code just select the dims and do Ctrl+c other dwg Ctrl+v. Edited September 9, 2023 by BIGAL Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.