nc2t 发表于 2006-8-23 10:40:00

关于拖动块的问题()

本帖最后由 作者 于 2006-8-27 22:49:27 编辑 <br /><br /> <P>我做了一个带属性定义的块表记录,和引用该块定义的块参照</P>
<P>当我使用AcEdJig拖动该块参照的时候会发现,在拖动的过程中,会出现在块中属性定义的tag中的字符串 和块的图形一起出现.也随着块中的图形一起动</P>
<P>其实属性定义的tag值,应该只是该属性的一个标识,但是为什么在块定义中的这个标识,会在拖动的过程中出现啊?</P>
<P>比如:块中有个属性定义,该属性定义的tag = "标识",这样在拖动这个块 的引用的同时,这个"标识"的字符也会随着图形一起动,其实应该不会出现这个字符串 啊</P>
<P>这个问题郁闷我好几天了,请哪为朋友指点一下 好么?</P>

nc2t 发表于 2006-8-30 10:50:00

<P>这么长时间也没有人能解决这个问题么?看来只好使用一个变通的方法了,</P>
<P>pAttDef-&gt;setHeight(0.00001)把高度值设置为最小,这样就看不见了;不过我还是不甘心,要是哪位兄弟知道该怎么解决这个问题,请赐教!</P>

nc2t 发表于 2006-8-30 10:54:00

其实这个问题就是:在拖动一个块引用的过程中,怎样才能不显示"该块引用的那个块"中的属性定义的Tag字符串

shinjikun 发表于 2006-8-30 15:48:00

<P>属性和属性定义的问题:</P>
<P>class bjt:<BR>&nbsp;public AcEdJig<BR>{<BR>&nbsp;AcGePoint3d mTo;<BR>&nbsp;AcDbBlockReference* br;<BR>public:<BR>&nbsp;AcDbObjectId append()<BR>&nbsp;{<BR>&nbsp;&nbsp;AcDbBlockTableRecord *btr;<BR>&nbsp;&nbsp;acdbOpenObject(btr,br-&gt;blockTableRecord(),kForRead);<BR>&nbsp;&nbsp;if(btr-&gt;hasAttributeDefinitions())<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;AcDbBlockTableRecordIterator *it;<BR>&nbsp;&nbsp;&nbsp;btr-&gt;newIterator(it);<BR>&nbsp;&nbsp;&nbsp;for(;!it-&gt;done();it-&gt;step())<BR>&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;AcDbEntity *pEnt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;it-&gt;getEntity(pEnt, AcDb::kForRead);</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;// Make sure the entity is an attribute definition<BR>&nbsp;&nbsp;&nbsp;&nbsp;// and not a constant.<BR>&nbsp;&nbsp;&nbsp;&nbsp;//<BR>&nbsp;&nbsp;&nbsp;&nbsp;AcDbAttributeDefinition *pAttdef = AcDbAttributeDefinition::cast(pEnt);<BR>&nbsp;&nbsp;&nbsp;&nbsp;if (pAttdef != NULL &amp;&amp; !pAttdef-&gt;isConstant()) <BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// We have a non-constant attribute definition,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// so build an attribute entity.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AcDbAttribute *pAtt = new AcDbAttribute();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pAtt-&gt;setPropertiesFrom(pAttdef);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pAtt-&gt;setInvisible(pAttdef-&gt;isInvisible());</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Translate the attribute by block reference.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// To be really correct, the entire block<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// reference transform should be applied here.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AcGePoint3d basePoint = pAttdef-&gt;position();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;basePoint += br-&gt;position().asVector();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pAtt-&gt;setPosition(basePoint);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pAtt-&gt;setHeight(pAttdef-&gt;height());<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pAtt-&gt;setRotation(pAttdef-&gt;rotation());<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pAtt-&gt;setTag(pAttdef-&gt;tag());<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pAtt-&gt;setFieldLength(25);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;char *pStr = pAttdef-&gt;tag();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pAtt-&gt;setTag(pStr);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;free(pStr);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pAtt-&gt;setFieldLength(pAttdef-&gt;fieldLength());</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pAtt-&gt;setTextString("Assigned Attribute Value");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;br-&gt;appendAttribute(pAtt);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pAtt-&gt;close();<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;pEnt-&gt;close();<BR>&nbsp;&nbsp;&nbsp;}</P>
<P>&nbsp;&nbsp;&nbsp;delete it;<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;btr-&gt;close();<BR>&nbsp;&nbsp;return AcEdJig::append();<BR>&nbsp;}<BR>&nbsp;//////////////////////////////////////////////////////////////////////////<BR>&nbsp;virtual DragStatus&nbsp;sampler()<BR>&nbsp;{<BR>&nbsp;&nbsp;DragStatus stat;<BR>&nbsp;&nbsp;setUserInputControls((UserInputControls)<BR>&nbsp;&nbsp;&nbsp;(AcEdJig::kAccept3dCoordinates<BR>&nbsp;&nbsp;&nbsp;| AcEdJig::kNoNegativeResponseAccepted<BR>&nbsp;&nbsp;&nbsp;| AcEdJig::kNoZeroResponseAccepted));</P>
<P>&nbsp;&nbsp;static AcGePoint3d axisPointTemp;<BR>&nbsp;&nbsp;stat = acquirePoint(mTo);<BR>&nbsp;&nbsp;if (axisPointTemp != mTo)<BR>&nbsp;&nbsp;&nbsp;axisPointTemp = mTo;<BR>&nbsp;&nbsp;else if (stat == AcEdJig::kNormal)<BR>&nbsp;&nbsp;&nbsp;return AcEdJig::kNoChange;<BR>&nbsp;&nbsp;return stat;<BR>&nbsp;}<BR>&nbsp;//////////////////////////////////////////////////////////////////////////<BR>&nbsp;virtual Adesk::Boolean&nbsp; update()<BR>&nbsp;{</P>
<P>&nbsp;&nbsp;br-&gt;setPosition(mTo);<BR>&nbsp;&nbsp;return Adesk::kTrue;<BR>&nbsp;}<BR>&nbsp;//////////////////////////////////////////////////////////////////////////<BR>&nbsp;virtual AcDbEntity* entity() const<BR>&nbsp;{<BR>&nbsp;&nbsp;return br;<BR>&nbsp;}<BR>&nbsp;//////////////////////////////////////////////////////////////////////////<BR>&nbsp;void start()<BR>&nbsp;{<BR>&nbsp;&nbsp;br=0;<BR>&nbsp;&nbsp;AcDbBlockTable *bt;<BR>&nbsp;&nbsp;acdbHostApplicationServices()-&gt;workingDatabase()-&gt;getBlockTable(bt,kForRead);<BR>&nbsp;&nbsp;AcDbObjectId bid;<BR>&nbsp;&nbsp;try<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;char text;<BR>&nbsp;&nbsp;&nbsp;if(RTNORM!=acedGetString(1,"input name",text))throw(0);<BR>&nbsp;&nbsp;&nbsp;if (bt-&gt;getAt(text,bid)!=eOk)throw(0);<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;catch(...)<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;bt-&gt;close();<BR>&nbsp;&nbsp;&nbsp;return;<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;bt-&gt;close();<BR>&nbsp;&nbsp;br=new AcDbBlockReference(AcGePoint3d::kOrigin,bid);<BR>&nbsp;&nbsp;setDispPrompt("Jig a Block");<BR>&nbsp;&nbsp;drag();<BR>&nbsp;&nbsp;append();<BR>&nbsp;}</P>
<P>};</P>
<P>&nbsp;另:</P>
<P>static void BlockJigTestnewJ(void)<BR>&nbsp;{<BR>&nbsp;&nbsp;// Add your code for command BlockJigTest.newJ here<BR>&nbsp;&nbsp;bjt b;<BR>&nbsp;&nbsp;b.start();<BR>&nbsp;}</P>

lyhnjuct 发表于 2006-9-5 12:50:00

<P>大侠们能否上传一个先动态创建块,在插入块参考时有橡皮条效果的例题??</P>
<P>QQ:78250323</P>
<P>EMAIL:LYHNJUCT@163.COM</P>

nc2t 发表于 2006-9-11 09:46:00

<P>使用jig好象也可以,我没有尝试过,你先研究研究,我也给你看看</P>
<P>使用jig拖动距离看看是不是能实现,我也是感觉而已</P>

YANGGY 发表于 2006-9-23 22:03:00

我做过无属性的<STRONG>拖动块,但我认为对属性的定义应在</STRONG>drag();之后&nbsp;&nbsp;append();之前定义则<STRONG>属性在拖动中不可见,除非属性模式是固定,建议为预置。</STRONG><BR>
页: [1]
查看完整版本: 关于拖动块的问题()